Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate default timeouts #3011

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cpp/src/Ice/DefaultsAndOverrides.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,24 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro

const_cast<chrono::milliseconds&>(defaultInvocationTimeout) =
chrono::milliseconds(properties->getIcePropertyAsInt("Ice.Default.InvocationTimeout"));
if (defaultInvocationTimeout.count() < 1 && defaultInvocationTimeout.count() != -1)
{
throw InitializationException(
pepone marked this conversation as resolved.
Show resolved Hide resolved
__FILE__,
__LINE__,
"invalid value for Ice.Default.InvocationTimeout " + to_string(defaultInvocationTimeout.count()) + "'");
pepone marked this conversation as resolved.
Show resolved Hide resolved
}

const_cast<chrono::seconds&>(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<bool&>(defaultPreferSecure) = properties->getIcePropertyAsInt("Ice.Default.PreferSecure") > 0;

Expand Down
25 changes: 18 additions & 7 deletions csharp/src/Ice/Internal/DefaultsAndOverrides.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
17 changes: 12 additions & 5 deletions java/src/Ice/src/main/java/com/zeroc/Ice/DefaultsAndOverrides.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading