diff --git a/cpp/src/Ice/DefaultsAndOverrides.cpp b/cpp/src/Ice/DefaultsAndOverrides.cpp index 4cde22cc46b..d7494f0a93d 100644 --- a/cpp/src/Ice/DefaultsAndOverrides.cpp +++ b/cpp/src/Ice/DefaultsAndOverrides.cpp @@ -65,8 +65,23 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro const_cast(defaultInvocationTimeout) = chrono::milliseconds(properties->getIcePropertyAsInt("Ice.Default.InvocationTimeout")); + if (defaultInvocationTimeout.count() < 1 && defaultInvocationTimeout.count() != -1) + { + throw InitializationException{ + __FILE__, + __LINE__, + "invalid value for Ice.Default.InvocationTimeout: " + to_string(defaultInvocationTimeout.count())}; + } + const_cast(defaultLocatorCacheTimeout) = chrono::seconds(properties->getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout")); + if (defaultLocatorCacheTimeout.count() < -1) + { + throw InitializationException{ + __FILE__, + __LINE__, + "invalid value for Ice.Default.LocatorCacheTimeout: " + to_string(defaultLocatorCacheTimeout.count())}; + } const_cast(defaultPreferSecure) = properties->getIcePropertyAsInt("Ice.Default.PreferSecure") > 0; diff --git a/csharp/src/Ice/Internal/DefaultsAndOverrides.cs b/csharp/src/Ice/Internal/DefaultsAndOverrides.cs index 095d654f194..47eae4650e7 100644 --- a/csharp/src/Ice/Internal/DefaultsAndOverrides.cs +++ b/csharp/src/Ice/Internal/DefaultsAndOverrides.cs @@ -80,16 +80,27 @@ internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger) throw new ParseException($"illegal value '{val}' in property Ice.Default.EndpointSelection; expected 'Random' or 'Ordered'"); } - defaultLocatorCacheTimeout = TimeSpan.FromSeconds( - properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout")); - defaultInvocationTimeout = TimeSpan.FromMilliseconds( - properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout")); + { + int value = properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout"); + if (value < -1) + { + throw new InitializationException($"invalid value for Ice.Default.LocatorCacheTimeout: {value}"); + } + defaultLocatorCacheTimeout = TimeSpan.FromSeconds(value); + } + + { + int value = properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout"); + if (value < 1 && value != -1) + { + throw new InitializationException($"invalid value for Ice.Default.InvocationTimeout: {value}"); + } + defaultInvocationTimeout = TimeSpan.FromMilliseconds(value); + } defaultPreferSecure = properties.getIcePropertyAsInt("Ice.Default.PreferSecure") > 0; - val = properties.getPropertyWithDefault( - "Ice.Default.EncodingVersion", - Ice.Util.encodingVersionToString(Ice.Util.currentEncoding)); + val = properties.getIceProperty("Ice.Default.EncodingVersion"); defaultEncoding = Ice.Util.stringToEncodingVersion(val); Protocol.checkSupportedEncoding(defaultEncoding); diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/DefaultsAndOverrides.java b/java/src/Ice/src/main/java/com/zeroc/Ice/DefaultsAndOverrides.java index a835051b0a5..b9258709ff8 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/DefaultsAndOverrides.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/DefaultsAndOverrides.java @@ -67,12 +67,19 @@ final class DefaultsAndOverrides { + "' in property Ice.Default.EndpointSelection; expected 'Random' or 'Ordered'"); } - defaultLocatorCacheTimeout = - Duration.ofSeconds( - properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout")); + intValue = properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout"); + if (intValue < -1) { + throw new InitializationException( + "invalid value for Ice.Default.LocatorCacheTimeout: " + intValue); + } + defaultLocatorCacheTimeout = Duration.ofSeconds(intValue); - defaultInvocationTimeout = - Duration.ofMillis(properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout")); + intValue = properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout"); + if (intValue < 1 && intValue != -1) { + throw new InitializationException( + "invalid value for Ice.Default.InvocationTimeout: " + intValue); + } + defaultInvocationTimeout = Duration.ofMillis(intValue); defaultPreferSecure = properties.getIcePropertyAsInt("Ice.Default.PreferSecure") > 0; diff --git a/js/src/Ice/DefaultsAndOverrides.js b/js/src/Ice/DefaultsAndOverrides.js index 191f67d1721..34170aa4d9d 100644 --- a/js/src/Ice/DefaultsAndOverrides.js +++ b/js/src/Ice/DefaultsAndOverrides.js @@ -37,14 +37,14 @@ export class DefaultsAndOverrides { this.defaultLocatorCacheTimeout = properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout"); if (this.defaultLocatorCacheTimeout < -1) { throw new InitializationException( - `invalid value for Ice.Default.LocatorCacheTimeout '${this.defaultLocatorCacheTimeout}'`, + `invalid value for Ice.Default.LocatorCacheTimeout: ${this.defaultLocatorCacheTimeout}`, ); } this.defaultInvocationTimeout = properties.getIcePropertyAsInt("Ice.Default.InvocationTimeout"); if (this.defaultInvocationTimeout < 1 && this.defaultInvocationTimeout !== -1) { throw new InitializationException( - `invalid value for Ice.Default.InvocationTimeout '${this.defaultInvocationTimeout}'`, + `invalid value for Ice.Default.InvocationTimeout: ${this.defaultInvocationTimeout}`, ); }