summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2014-08-19 13:10:29 -0230
committerDwayne Boone <dwayne@zeroc.com>2014-08-19 13:10:29 -0230
commitc6d20e1e1afc75f8bd889c093ccbffb247ec30cb (patch)
tree19443a7e7263ce1d715dad261b4574942c419552 /java/src
parentFixed (ICE-5592) - Add IceSSL.FindCert for OS X and Windows (diff)
downloadice-c6d20e1e1afc75f8bd889c093ccbffb247ec30cb.tar.bz2
ice-c6d20e1e1afc75f8bd889c093ccbffb247ec30cb.tar.xz
ice-c6d20e1e1afc75f8bd889c093ccbffb247ec30cb.zip
ICE-3492 handle improper settings for timeout values
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/ObjectPrxHelperBase.java12
-rw-r--r--java/src/IceInternal/DefaultsAndOverrides.java90
-rw-r--r--java/src/IceInternal/Instance.java8
-rw-r--r--java/src/IceInternal/ReferenceFactory.java34
4 files changed, 128 insertions, 16 deletions
diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java
index 2a80a2fab65..cb7623ecbdd 100644
--- a/java/src/Ice/ObjectPrxHelperBase.java
+++ b/java/src/Ice/ObjectPrxHelperBase.java
@@ -1837,6 +1837,10 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
public final ObjectPrx
ice_locatorCacheTimeout(int newTimeout)
{
+ if(newTimeout < -1)
+ {
+ throw new IllegalArgumentException("invalid value passed to ice_locatorCacheTimeout: " + newTimeout);
+ }
if(newTimeout == _reference.getLocatorCacheTimeout())
{
return this;
@@ -1856,6 +1860,10 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
public final ObjectPrx
ice_invocationTimeout(int newTimeout)
{
+ if(newTimeout < 1 && newTimeout != -1)
+ {
+ throw new IllegalArgumentException("invalid value passed to ice_invocationTimeout: " + newTimeout);
+ }
if(newTimeout == _reference.getInvocationTimeout())
{
return this;
@@ -2317,6 +2325,10 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
public final ObjectPrx
ice_timeout(int t)
{
+ if(t < 1 && t != -1)
+ {
+ throw new IllegalArgumentException("invalid value passed to ice_timeout: " + t);
+ }
IceInternal.Reference ref = _reference.changeTimeout(t);
if(ref.equals(_reference))
{
diff --git a/java/src/IceInternal/DefaultsAndOverrides.java b/java/src/IceInternal/DefaultsAndOverrides.java
index c86c0bc6c5a..5dbdcc1a0dc 100644
--- a/java/src/IceInternal/DefaultsAndOverrides.java
+++ b/java/src/IceInternal/DefaultsAndOverrides.java
@@ -11,9 +11,10 @@ package IceInternal;
public final class DefaultsAndOverrides
{
- DefaultsAndOverrides(Ice.Properties properties)
+ DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger)
{
String value;
+ int intValue;
defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp");
@@ -46,7 +47,19 @@ public final class DefaultsAndOverrides
if(!value.isEmpty())
{
overrideTimeout = true;
- overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout");
+ intValue = properties.getPropertyAsInt("Ice.Override.Timeout");
+ if(intValue < 0 && intValue != -1)
+ {
+ overrideTimeoutValue = -1;
+ StringBuffer msg = new StringBuffer("invalid value for Ice.Override.Timeout `");
+ msg.append(properties.getProperty("Ice.Override.Timeout"));
+ msg.append("': defaulting to -1");
+ logger.warning(msg.toString());
+ }
+ else
+ {
+ overrideTimeoutValue = intValue;
+ }
}
else
{
@@ -58,7 +71,19 @@ public final class DefaultsAndOverrides
if(!value.isEmpty())
{
overrideConnectTimeout = true;
- overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout");
+ intValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout");
+ if(intValue < 0 && intValue != -1)
+ {
+ overrideConnectTimeoutValue = -1;
+ StringBuffer msg = new StringBuffer("invalid value for Ice.Override.ConnectTimeout `");
+ msg.append(properties.getProperty("Ice.Override.ConnectTimeout"));
+ msg.append("': defaulting to -1");
+ logger.warning(msg.toString());
+ }
+ else
+ {
+ overrideConnectTimeoutValue = intValue;
+ }
}
else
{
@@ -70,7 +95,19 @@ public final class DefaultsAndOverrides
if(!value.isEmpty())
{
overrideCloseTimeout = true;
- overrideCloseTimeoutValue = properties.getPropertyAsInt("Ice.Override.CloseTimeout");
+ intValue = properties.getPropertyAsInt("Ice.Override.CloseTimeout");
+ if(intValue < 0 && intValue != -1)
+ {
+ overrideCloseTimeoutValue = -1;
+ StringBuffer msg = new StringBuffer("invalid value for Ice.Override.CloseTimeout `");
+ msg.append(properties.getProperty("Ice.Override.CloseTimeout"));
+ msg.append("': defaulting to -1");
+ logger.warning(msg.toString());
+ }
+ else
+ {
+ overrideCloseTimeoutValue = intValue;
+ }
}
else
{
@@ -127,14 +164,47 @@ public final class DefaultsAndOverrides
throw ex;
}
- defaultTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000);
- if(defaultTimeout < 1 && defaultTimeout != -1)
+ intValue = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000);
+ if(intValue < 1 && intValue != -1)
+ {
+ defaultTimeout = 60000;
+ StringBuffer msg = new StringBuffer("invalid value for Ice.Default.Timeout `");
+ msg.append(properties.getProperty("Ice.Default.Timeout"));
+ msg.append("': defaulting to 60000");
+ logger.warning(msg.toString());
+ }
+ else
+ {
+ defaultTimeout = intValue;
+ }
+
+ intValue = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
+ if(intValue < -1)
+ {
+ defaultLocatorCacheTimeout = -1;
+ StringBuffer msg = new StringBuffer("invalid value for Ice.Default.LocatorCacheTimeout `");
+ msg.append(properties.getProperty("Ice.Default.LocatorCacheTimeout"));
+ msg.append("': defaulting to -1");
+ logger.warning(msg.toString());
+ }
+ else
+ {
+ defaultLocatorCacheTimeout = intValue;
+ }
+
+ intValue = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1);
+ if(intValue < 1 && intValue != -1)
+ {
+ defaultInvocationTimeout = -1;
+ StringBuffer msg = new StringBuffer("invalid value for Ice.Default.InvocationTimeout `");
+ msg.append(properties.getProperty("Ice.Default.InvocationTimeout"));
+ msg.append("': defaulting to -1");
+ logger.warning(msg.toString());
+ }
+ else
{
- throw new Ice.InitializationException("invalid value for Ice.Default.Timeout: `" +
- properties.getProperty("Ice.Default.Timeout") + "'");
+ defaultInvocationTimeout = intValue;
}
- defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
- defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1);
defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java
index 91a309ee34a..d091c0fd45c 100644
--- a/java/src/IceInternal/Instance.java
+++ b/java/src/IceInternal/Instance.java
@@ -715,7 +715,7 @@ public final class Instance
_traceLevels = new TraceLevels(_initData.properties);
- _defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties);
+ _defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties, _initData.logger);
_clientACM = new ACMConfig(_initData.properties,
_initData.logger,
@@ -795,13 +795,13 @@ public final class Instance
ProtocolInstance tcpProtocolInstance = new ProtocolInstance(this, Ice.TCPEndpointType.value, "tcp");
EndpointFactory tcpEndpointFactory = new TcpEndpointFactory(tcpProtocolInstance);
_endpointFactoryManager.add(tcpEndpointFactory);
-
+
ProtocolInstance udpProtocolInstance = new ProtocolInstance(this, Ice.UDPEndpointType.value, "udp");
EndpointFactory udpEndpointFactory = new UdpEndpointFactory(udpProtocolInstance);
_endpointFactoryManager.add(udpEndpointFactory);
-
+
ProtocolInstance wsProtocolInstance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws");
- EndpointFactory wsEndpointFactory = new WSEndpointFactory(wsProtocolInstance,
+ EndpointFactory wsEndpointFactory = new WSEndpointFactory(wsProtocolInstance,
tcpEndpointFactory.clone(wsProtocolInstance));
_endpointFactoryManager.add(wsEndpointFactory);
diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java
index c6914703f80..53d6e4c7873 100644
--- a/java/src/IceInternal/ReferenceFactory.java
+++ b/java/src/IceInternal/ReferenceFactory.java
@@ -838,10 +838,40 @@ public final class ReferenceFactory
}
property = propertyPrefix + ".LocatorCacheTimeout";
- locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout);
+ String value = properties.getProperty(property);
+ if(!value.isEmpty())
+ {
+ locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout);
+ if(locatorCacheTimeout < -1)
+ {
+ locatorCacheTimeout = -1;
+
+ StringBuffer msg = new StringBuffer("invalid value for ");
+ msg.append(property);
+ msg.append(" '");
+ msg.append(properties.getProperty(property));
+ msg.append("': defaulting to -1");
+ _instance.initializationData().logger.warning(msg.toString());
+ }
+ }
property = propertyPrefix + ".InvocationTimeout";
- invocationTimeout = properties.getPropertyAsIntWithDefault(property, invocationTimeout);
+ value = properties.getProperty(property);
+ if(!value.isEmpty())
+ {
+ invocationTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout);
+ if(invocationTimeout < 1 && invocationTimeout != -1)
+ {
+ invocationTimeout = -1;
+
+ StringBuffer msg = new StringBuffer("invalid value for ");
+ msg.append(property);
+ msg.append(" '");
+ msg.append(properties.getProperty(property));
+ msg.append("': defaulting to -1");
+ _instance.initializationData().logger.warning(msg.toString());
+ }
+ }
property = propertyPrefix + ".Context.";
java.util.Map<String, String> contexts = properties.getPropertiesForPrefix(property);