summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2014-08-08 13:33:18 -0230
committerDwayne Boone <dwayne@zeroc.com>2014-08-08 13:33:18 -0230
commitc540f34ba2dd245e88cee99f39552efbd44c91e1 (patch)
treea637ce6dce7ad189069e784f21d5166c6a98aff1 /java/src
parentFixed (ICE-5583) - Consider adding IceSSL.CertAuthFile to C# implementation (diff)
downloadice-c540f34ba2dd245e88cee99f39552efbd44c91e1.tar.bz2
ice-c540f34ba2dd245e88cee99f39552efbd44c91e1.tar.xz
ice-c540f34ba2dd245e88cee99f39552efbd44c91e1.zip
ICE-5596 add Ice.Default.Timeout property
Diffstat (limited to 'java/src')
-rw-r--r--java/src/IceInternal/DefaultsAndOverrides.java7
-rw-r--r--java/src/IceInternal/PropertyNames.java1
-rw-r--r--java/src/IceInternal/ProtocolInstance.java5
-rw-r--r--java/src/IceInternal/TcpEndpointI.java41
-rw-r--r--java/src/IceSSL/EndpointI.java41
5 files changed, 81 insertions, 14 deletions
diff --git a/java/src/IceInternal/DefaultsAndOverrides.java b/java/src/IceInternal/DefaultsAndOverrides.java
index db876a52c1f..c86c0bc6c5a 100644
--- a/java/src/IceInternal/DefaultsAndOverrides.java
+++ b/java/src/IceInternal/DefaultsAndOverrides.java
@@ -127,6 +127,12 @@ public final class DefaultsAndOverrides
throw ex;
}
+ defaultTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000);
+ if(defaultTimeout < 1 && defaultTimeout != -1)
+ {
+ throw new Ice.InitializationException("invalid value for Ice.Default.Timeout: `" +
+ properties.getProperty("Ice.Default.Timeout") + "'");
+ }
defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1);
@@ -146,6 +152,7 @@ public final class DefaultsAndOverrides
final public String defaultProtocol;
final public boolean defaultCollocationOptimization;
final public Ice.EndpointSelectionType defaultEndpointSelection;
+ final public int defaultTimeout;
final public int defaultLocatorCacheTimeout;
final public int defaultInvocationTimeout;
final public boolean defaultPreferSecure;
diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java
index f27b671e3bc..e0b7dd7b9c9 100644
--- a/java/src/IceInternal/PropertyNames.java
+++ b/java/src/IceInternal/PropertyNames.java
@@ -109,6 +109,7 @@ public final class PropertyNames
new Property("Ice\\.Default\\.Router", false, null),
new Property("Ice\\.Default\\.SlicedFormat", false, null),
new Property("Ice\\.Default\\.SourceAddress", false, null),
+ new Property("Ice\\.Default\\.Timeout", false, null),
new Property("Ice\\.IPv4", false, null),
new Property("Ice\\.IPv6", false, null),
new Property("Ice\\.EventLog\\.Source", false, null),
diff --git a/java/src/IceInternal/ProtocolInstance.java b/java/src/IceInternal/ProtocolInstance.java
index f78060cc172..9e217d9df4a 100644
--- a/java/src/IceInternal/ProtocolInstance.java
+++ b/java/src/IceInternal/ProtocolInstance.java
@@ -77,6 +77,11 @@ public class ProtocolInstance
return _instance.defaultsAndOverrides().defaultEncoding;
}
+ public int defaultTimeout()
+ {
+ return _instance.defaultsAndOverrides().defaultTimeout;
+ }
+
public NetworkProxy networkProxy()
{
return _instance.networkProxy();
diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java
index 564e5292371..f002f0f4101 100644
--- a/java/src/IceInternal/TcpEndpointI.java
+++ b/java/src/IceInternal/TcpEndpointI.java
@@ -22,7 +22,7 @@ final class TcpEndpointI extends IPEndpointI
public TcpEndpointI(ProtocolInstance instance)
{
super(instance);
- _timeout = -1;
+ _timeout = -2;
_compress = false;
}
@@ -179,7 +179,11 @@ final class TcpEndpointI extends IPEndpointI
//
String s = super.options();
- if(_timeout != -1)
+ if(_timeout == -1)
+ {
+ s += " -t infinite";
+ }
+ else
{
s += " -t " + _timeout;
}
@@ -260,6 +264,17 @@ final class TcpEndpointI extends IPEndpointI
}
@Override
+ public void initWithOptions(java.util.ArrayList<String> args, boolean oaEndpoint)
+ {
+ super.initWithOptions(args, oaEndpoint);
+
+ if(_timeout == -2)
+ {
+ _timeout = _instance.defaultTimeout();
+ }
+ }
+
+ @Override
protected boolean checkOption(String option, String argument, String endpoint)
{
if(super.checkOption(option, argument, endpoint))
@@ -276,14 +291,26 @@ final class TcpEndpointI extends IPEndpointI
throw new Ice.EndpointParseException("no argument provided for -t option in endpoint " + endpoint);
}
- try
+ if(argument.equals("infinite"))
{
- _timeout = Integer.parseInt(argument);
+ _timeout = -1;
}
- catch(NumberFormatException ex)
+ else
{
- throw new Ice.EndpointParseException("invalid timeout value `" + argument +
- "' in endpoint " + endpoint);
+ try
+ {
+ _timeout = Integer.parseInt(argument);
+ if(_timeout < 1)
+ {
+ throw new Ice.EndpointParseException("invalid timeout value `" + argument +
+ "' in endpoint " + endpoint);
+ }
+ }
+ catch(NumberFormatException ex)
+ {
+ throw new Ice.EndpointParseException("invalid timeout value `" + argument +
+ "' in endpoint " + endpoint);
+ }
}
return true;
diff --git a/java/src/IceSSL/EndpointI.java b/java/src/IceSSL/EndpointI.java
index 0df306e6373..82bb7a82fd6 100644
--- a/java/src/IceSSL/EndpointI.java
+++ b/java/src/IceSSL/EndpointI.java
@@ -24,7 +24,7 @@ final class EndpointI extends IceInternal.IPEndpointI
{
super(instance);
_instance = instance;
- _timeout = -1;
+ _timeout = -2;
_compress = false;
}
@@ -170,7 +170,11 @@ final class EndpointI extends IceInternal.IPEndpointI
//
String s = super.options();
- if(_timeout != -1)
+ if(_timeout == -1)
+ {
+ s += " -t infinite";
+ }
+ else
{
s += " -t " + _timeout;
}
@@ -246,6 +250,17 @@ final class EndpointI extends IceInternal.IPEndpointI
}
}
+ @Override
+ public void initWithOptions(java.util.ArrayList<String> args, boolean oaEndpoint)
+ {
+ super.initWithOptions(args, oaEndpoint);
+
+ if(_timeout == -2)
+ {
+ _timeout = _instance.defaultTimeout();
+ }
+ }
+
protected boolean checkOption(String option, String argument, String endpoint)
{
if(super.checkOption(option, argument, endpoint))
@@ -262,14 +277,26 @@ final class EndpointI extends IceInternal.IPEndpointI
throw new Ice.EndpointParseException("no argument provided for -t option in endpoint " + endpoint);
}
- try
+ if(argument.equals("infinite"))
{
- _timeout = Integer.parseInt(argument);
+ _timeout = -1;
}
- catch(NumberFormatException ex)
+ else
{
- throw new Ice.EndpointParseException("invalid timeout value `" + argument + "' in endpoint " +
- endpoint);
+ try
+ {
+ _timeout = Integer.parseInt(argument);
+ if(_timeout < 1)
+ {
+ throw new Ice.EndpointParseException("invalid timeout value `" + argument +
+ "' in endpoint " + endpoint);
+ }
+ }
+ catch(NumberFormatException ex)
+ {
+ throw new Ice.EndpointParseException("invalid timeout value `" + argument +
+ "' in endpoint " + endpoint);
+ }
}
return true;