summaryrefslogtreecommitdiff
path: root/cpp
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 /cpp
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 'cpp')
-rw-r--r--cpp/src/Ice/DefaultsAndOverrides.cpp45
-rw-r--r--cpp/src/Ice/DefaultsAndOverrides.h2
-rw-r--r--cpp/src/Ice/Instance.cpp35
-rw-r--r--cpp/src/Ice/Proxy.cpp174
-rw-r--r--cpp/src/Ice/ReferenceFactory.cpp66
-rw-r--r--cpp/test/Ice/proxy/AllTests.cpp82
6 files changed, 283 insertions, 121 deletions
diff --git a/cpp/src/Ice/DefaultsAndOverrides.cpp b/cpp/src/Ice/DefaultsAndOverrides.cpp
index fc4cf920a7f..42757693deb 100644
--- a/cpp/src/Ice/DefaultsAndOverrides.cpp
+++ b/cpp/src/Ice/DefaultsAndOverrides.cpp
@@ -10,6 +10,7 @@
#include <IceUtil/DisableWarnings.h>
#include <Ice/DefaultsAndOverrides.h>
#include <Ice/Properties.h>
+#include <Ice/LoggerUtil.h>
#include <Ice/LocalException.h>
using namespace std;
@@ -18,7 +19,7 @@ using namespace IceInternal;
IceUtil::Shared* IceInternal::upCast(DefaultsAndOverrides* p) { return p; }
-IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& properties) :
+IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& properties, const LoggerPtr& logger) :
overrideTimeout(false),
overrideTimeoutValue(-1),
overrideConnectTimeout(false),
@@ -61,6 +62,13 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro
{
const_cast<bool&>(overrideTimeout) = true;
const_cast<Int&>(overrideTimeoutValue) = properties->getPropertyAsInt("Ice.Override.Timeout");
+ if(overrideTimeoutValue < 1 && overrideTimeoutValue != -1)
+ {
+ const_cast<Int&>(overrideTimeoutValue) = -1;
+ Warning out(logger);
+ out << "invalid value for Ice.Override.Timeout `" << properties->getProperty("Ice.Override.Timeout")
+ << "': defaulting to -1";
+ }
}
value = properties->getProperty("Ice.Override.ConnectTimeout");
@@ -68,6 +76,13 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro
{
const_cast<bool&>(overrideConnectTimeout) = true;
const_cast<Int&>(overrideConnectTimeoutValue) = properties->getPropertyAsInt("Ice.Override.ConnectTimeout");
+ if(overrideConnectTimeoutValue < 1 && overrideConnectTimeoutValue != -1)
+ {
+ const_cast<Int&>(overrideConnectTimeoutValue) = -1;
+ Warning out(logger);
+ out << "invalid value for Ice.Override.ConnectTimeout `"
+ << properties->getProperty("Ice.Override.ConnectTimeout") << "': defaulting to -1";
+ }
}
value = properties->getProperty("Ice.Override.CloseTimeout");
@@ -75,6 +90,13 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro
{
const_cast<bool&>(overrideCloseTimeout) = true;
const_cast<Int&>(overrideCloseTimeoutValue) = properties->getPropertyAsInt("Ice.Override.CloseTimeout");
+ if(overrideCloseTimeoutValue < 1 && overrideCloseTimeoutValue != -1)
+ {
+ const_cast<Int&>(overrideCloseTimeoutValue) = -1;
+ Warning out(logger);
+ out << "invalid value for Ice.Override.CloseTimeout `"
+ << properties->getProperty("Ice.Override.CloseTimeout") << "': defaulting to -1";
+ }
}
value = properties->getProperty("Ice.Override.Compress");
@@ -114,16 +136,31 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro
properties->getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000);
if(defaultTimeout < 1 && defaultTimeout != -1)
{
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "invalid value for Ice.Default.Timeout: `" + properties->getProperty("Ice.Default.Timeout") + "'";
- throw ex;
+ const_cast<Int&>(defaultTimeout) = 60000;
+ Warning out(logger);
+ out << "invalid value for Ice.Default.Timeout `" << properties->getProperty("Ice.Default.Timeout")
+ << "': defaulting to 60000";
}
const_cast<int&>(defaultInvocationTimeout) =
properties->getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1);
+ if(defaultInvocationTimeout < 1 && defaultInvocationTimeout != -1)
+ {
+ const_cast<Int&>(defaultInvocationTimeout) = -1;
+ Warning out(logger);
+ out << "invalid value for Ice.Default.InvocationTimeout `"
+ << properties->getProperty("Ice.Default.InvocationTimeout") << "': defaulting to -1";
+ }
const_cast<int&>(defaultLocatorCacheTimeout) =
properties->getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
+ if(defaultLocatorCacheTimeout < -1)
+ {
+ const_cast<Int&>(defaultLocatorCacheTimeout) = -1;
+ Warning out(logger);
+ out << "invalid value for Ice.Default.LocatorCacheTimeout `"
+ << properties->getProperty("Ice.Default.LocatorCacheTimeout") << "': defaulting to -1";
+ }
const_cast<bool&>(defaultPreferSecure) =
properties->getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
diff --git a/cpp/src/Ice/DefaultsAndOverrides.h b/cpp/src/Ice/DefaultsAndOverrides.h
index 01d6ec345c7..8e67e9af76b 100644
--- a/cpp/src/Ice/DefaultsAndOverrides.h
+++ b/cpp/src/Ice/DefaultsAndOverrides.h
@@ -26,7 +26,7 @@ class DefaultsAndOverrides : public ::IceUtil::Shared
{
public:
- DefaultsAndOverrides(const ::Ice::PropertiesPtr&);
+ DefaultsAndOverrides(const ::Ice::PropertiesPtr&, const ::Ice::LoggerPtr&);
std::string defaultHost;
Address defaultSourceAddress;
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 52c29e7d3b9..a3a66fe904e 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -1071,7 +1071,8 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
const_cast<TraceLevelsPtr&>(_traceLevels) = new TraceLevels(_initData.properties);
- const_cast<DefaultsAndOverridesPtr&>(_defaultsAndOverrides) = new DefaultsAndOverrides(_initData.properties);
+ const_cast<DefaultsAndOverridesPtr&>(_defaultsAndOverrides) =
+ new DefaultsAndOverrides(_initData.properties, _initData.logger);
const ACMConfig defaultClientACM(_initData.properties, _initData.logger, "Ice.ACM", ACMConfig(false));
const ACMConfig defaultServerACM(_initData.properties, _initData.logger, "Ice.ACM", ACMConfig(true));
@@ -1176,7 +1177,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
_endpointFactoryManager->add(sslEndpointFactory);
ProtocolInstancePtr wssProtocolInstance = new ProtocolInstance(this, WSSEndpointType, "wss");
- EndpointFactoryPtr wssEndpointFactory = new WSEndpointFactory(wssProtocolInstance,
+ EndpointFactoryPtr wssEndpointFactory = new WSEndpointFactory(wssProtocolInstance,
sslEndpointFactory->clone(wssProtocolInstance));
_endpointFactoryManager->add(wssEndpointFactory);
#endif
@@ -1185,9 +1186,9 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
_endpointFactoryManager->add(udpEndpointFactory);
ProtocolInstancePtr wsProtocolInstance = new ProtocolInstance(this, WSEndpointType, "ws");
- EndpointFactoryPtr wsEndpointFactory = new WSEndpointFactory(wsProtocolInstance,
+ EndpointFactoryPtr wsEndpointFactory = new WSEndpointFactory(wsProtocolInstance,
tcpEndpointFactory->clone(wsProtocolInstance));
-
+
_endpointFactoryManager->add(wsEndpointFactory);
_dynamicLibraryList = new DynamicLibraryList;
@@ -1282,29 +1283,29 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[], const Ice::Communica
//
StringSeq facetSeq = _initData.properties->getPropertyAsList("Ice.Admin.Facets");
-
+
if(!facetSeq.empty())
{
_adminFacetFilter.insert(facetSeq.begin(), facetSeq.end());
}
_adminFacets.insert(FacetMap::value_type("Process", new ProcessI(communicator)));
-
+
string loggerFacetName = _initData.properties->getPropertyWithDefault("Ice.Admin.Logger", "Logger");
-
- bool insertLoggerFacet =
+
+ bool insertLoggerFacet =
(_adminFacetFilter.empty() || _adminFacetFilter.find(loggerFacetName) != _adminFacetFilter.end()) &&
_initData.properties->getProperty("Ice.Admin.Endpoints") != "";
-
+
if(loggerFacetName != "Logger" || insertLoggerFacet)
{
//
// Set up a new Logger
- //
+ //
Ice::LoggerAdminLoggerPtr logger = createLoggerAdminLogger(loggerFacetName,
- _initData.properties,
+ _initData.properties,
_initData.logger);
setLogger(logger);
-
+
if(insertLoggerFacet)
{
logger->addAdminFacet(communicator);
@@ -1313,13 +1314,13 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[], const Ice::Communica
// Else, this new logger & facet is useful for "slave" communicators like IceBox services.
//
}
-
+
PropertiesAdminIPtr props = new PropertiesAdminI("Properties", _initData.properties, _initData.logger);
_adminFacets.insert(FacetMap::value_type("Properties", props));
-
+
_metricsAdmin = new MetricsAdminI(_initData.properties, _initData.logger);
_adminFacets.insert(FacetMap::value_type("Metrics", _metricsAdmin));
-
+
//
// Setup the communicator observer only if the user didn't already set an
// Ice observer resolver and if the admininistrative endpoints are set.
@@ -1328,7 +1329,7 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[], const Ice::Communica
_initData.properties->getProperty("Ice.Admin.Endpoints") != "")
{
_observer = new CommunicatorObserverI(_metricsAdmin, _initData.observer);
-
+
//
// Make sure the admin plugin receives property updates.
//
@@ -1517,7 +1518,7 @@ IceInternal::Instance::destroy()
_observer->setObserverUpdater(0); // Break cyclic reference count.
}
}
-
+
Ice::LoggerAdminLoggerPtr logger = Ice::LoggerAdminLoggerPtr::dynamicCast(_initData.logger);
if(logger)
{
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index 41b46165524..20b04eee154 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -79,13 +79,13 @@ IceInternal::Cpp11FnCallbackNC::Cpp11FnCallbackNC(const ::std::function<void (co
{
}
-IceInternal::CallbackBasePtr
+IceInternal::CallbackBasePtr
IceInternal::Cpp11FnCallbackNC::verify(const ::Ice::LocalObjectPtr&)
{
return this;
}
-void
+void
IceInternal::Cpp11FnCallbackNC::sent(const ::Ice::AsyncResultPtr& result) const
{
if(_sent != nullptr)
@@ -94,13 +94,13 @@ IceInternal::Cpp11FnCallbackNC::sent(const ::Ice::AsyncResultPtr& result) const
}
}
-bool
+bool
IceInternal::Cpp11FnCallbackNC::hasSentCallback() const
{
return _sent != nullptr;
}
-void
+void
IceInternal::Cpp11FnCallbackNC::exception(const ::Ice::AsyncResultPtr&, const ::Ice::Exception& ex) const
{
if(_exception != nullptr)
@@ -117,7 +117,7 @@ IceInternal::Cpp11FnOnewayCallbackNC::Cpp11FnOnewayCallbackNC(const ::std::funct
{
CallbackBase::checkCallback(true, cb || excb != nullptr);
}
-
+
void
IceInternal::Cpp11FnOnewayCallbackNC::completed(const ::Ice::AsyncResultPtr& result) const
{
@@ -231,27 +231,27 @@ IceProxy::Ice::Object::begin_ice_isA(const string& typeId,
#ifdef ICE_CPP11
-Ice::AsyncResultPtr
+Ice::AsyncResultPtr
IceProxy::Ice::Object::__begin_ice_isA(
- const ::std::string& typeId,
+ const ::std::string& typeId,
const ::Ice::Context* ctx,
- const ::IceInternal::Function<void (bool)>& response,
+ const ::IceInternal::Function<void (bool)>& response,
const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception,
const ::IceInternal::Function<void (bool)>& sent)
{
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
-
- Cpp11CB(const ::std::function<void (bool)>& responseFunc,
- const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc,
+
+ Cpp11CB(const ::std::function<void (bool)>& responseFunc,
+ const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc,
const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
}
-
+
virtual void completed(const ::Ice::AsyncResultPtr& __result) const
{
::Ice::ObjectPrx __proxy = ::Ice::ObjectPrx::uncheckedCast(__result->getProxy());
@@ -270,35 +270,35 @@ IceProxy::Ice::Object::__begin_ice_isA(
_response(__ret);
}
}
-
+
private:
-
+
::std::function<void (bool)> _response;
};
return begin_ice_isA(typeId, ctx, new Cpp11CB(response, exception, sent), 0);
}
-Ice::AsyncResultPtr
+Ice::AsyncResultPtr
IceProxy::Ice::Object::__begin_ice_id(
const ::Ice::Context* ctx,
- const ::IceInternal::Function<void (const ::std::string&)>& response,
+ const ::IceInternal::Function<void (const ::std::string&)>& response,
const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception,
const ::IceInternal::Function<void (bool)>& sent)
{
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
-
- Cpp11CB(const ::std::function<void (const ::std::string&)>& responseFunc,
- const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc,
+
+ Cpp11CB(const ::std::function<void (const ::std::string&)>& responseFunc,
+ const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc,
const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
}
-
+
virtual void completed(const ::Ice::AsyncResultPtr& __result) const
{
::Ice::ObjectPrx __proxy = ::Ice::ObjectPrx::uncheckedCast(__result->getProxy());
@@ -317,15 +317,15 @@ IceProxy::Ice::Object::__begin_ice_id(
_response(__ret);
}
}
-
+
private:
-
+
::std::function<void (const ::std::string&)> _response;
};
return begin_ice_id(ctx, new Cpp11CB(response, exception, sent), 0);
}
-
-Ice::AsyncResultPtr
+
+Ice::AsyncResultPtr
IceProxy::Ice::Object::__begin_ice_ids(
const ::Ice::Context* ctx,
const ::IceInternal::Function<void (const ::std::vector< ::std::string>&)>& response,
@@ -335,16 +335,16 @@ IceProxy::Ice::Object::__begin_ice_ids(
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
-
- Cpp11CB(const ::std::function<void (const ::std::vector< ::std::string>&)>& responseFunc,
- const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc,
+
+ Cpp11CB(const ::std::function<void (const ::std::vector< ::std::string>&)>& responseFunc,
+ const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc,
const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
}
-
+
virtual void completed(const ::Ice::AsyncResultPtr& __result) const
{
::Ice::ObjectPrx __proxy = ::Ice::ObjectPrx::uncheckedCast(__result->getProxy());
@@ -363,18 +363,18 @@ IceProxy::Ice::Object::__begin_ice_ids(
_response(__ret);
}
}
-
+
private:
-
+
::std::function<void (const ::std::vector< ::std::string>&)> _response;
};
return begin_ice_ids(ctx, new Cpp11CB(response, exception, sent), 0);
}
-Ice::AsyncResultPtr
+Ice::AsyncResultPtr
IceProxy::Ice::Object::__begin_ice_invoke(
- const ::std::string& operation,
- ::Ice::OperationMode mode,
+ const ::std::string& operation,
+ ::Ice::OperationMode mode,
const ::std::vector< ::Ice::Byte>& inParams,
const ::Ice::Context* ctx,
const ::IceInternal::Function<void (bool, const ::std::vector< ::Ice::Byte>&)>& response,
@@ -384,16 +384,16 @@ IceProxy::Ice::Object::__begin_ice_invoke(
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
-
- Cpp11CB(const ::std::function<void (bool, const ::std::vector< ::Ice::Byte>&)>& responseFunc,
- const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc,
+
+ Cpp11CB(const ::std::function<void (bool, const ::std::vector< ::Ice::Byte>&)>& responseFunc,
+ const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc,
const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
}
-
+
virtual void completed(const ::Ice::AsyncResultPtr& __result) const
{
::Ice::ObjectPrx __proxy = ::Ice::ObjectPrx::uncheckedCast(__result->getProxy());
@@ -413,19 +413,19 @@ IceProxy::Ice::Object::__begin_ice_invoke(
_response(__ret, p1);
}
}
-
+
private:
-
+
::std::function<void (bool, const ::std::vector< ::Ice::Byte>&)> _response;
};
-
+
return begin_ice_invoke(operation, mode, inParams, ctx, new Cpp11CB(response, exception, sent), 0);
}
-
-Ice::AsyncResultPtr
+
+Ice::AsyncResultPtr
IceProxy::Ice::Object::__begin_ice_invoke(
const ::std::string& operation,
- ::Ice::OperationMode mode,
+ ::Ice::OperationMode mode,
const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams,
const ::Ice::Context* ctx,
const ::IceInternal::Function<void (bool, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&)>& response,
@@ -435,17 +435,17 @@ IceProxy::Ice::Object::__begin_ice_invoke(
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
-
- Cpp11CB(const ::std::function<void (bool, const ::std::pair<const ::Ice::Byte*,
+
+ Cpp11CB(const ::std::function<void (bool, const ::std::pair<const ::Ice::Byte*,
const ::Ice::Byte*>&)>& responseFunc,
- const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc,
+ const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc,
const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, _response || _exception != nullptr);
}
-
+
virtual void completed(const ::Ice::AsyncResultPtr& __result) const
{
bool __ret;
@@ -464,9 +464,9 @@ IceProxy::Ice::Object::__begin_ice_invoke(
_response(__ret, p1);
}
}
-
+
private:
-
+
::std::function<void (bool, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&)> _response;
};
return begin_ice_invoke(operation, mode, inParams, ctx, new Cpp11CB(response, exception, sent), 0);
@@ -522,7 +522,7 @@ IceProxy::Ice::Object::ice_ping(const Context* context)
}
AsyncResultPtr
-IceProxy::Ice::Object::begin_ice_ping(const Context* ctx,
+IceProxy::Ice::Object::begin_ice_ping(const Context* ctx,
const ::IceInternal::CallbackBasePtr& del,
const ::Ice::LocalObjectPtr& cookie)
{
@@ -595,7 +595,7 @@ IceProxy::Ice::Object::ice_id(const Context* context)
}
AsyncResultPtr
-IceProxy::Ice::Object::begin_ice_ids(const Context* ctx,
+IceProxy::Ice::Object::begin_ice_ids(const Context* ctx,
const ::IceInternal::CallbackBasePtr& del,
const ::Ice::LocalObjectPtr& cookie)
{
@@ -638,7 +638,7 @@ IceProxy::Ice::Object::end_ice_ids(const AsyncResultPtr& __result)
}
AsyncResultPtr
-IceProxy::Ice::Object::begin_ice_id(const Context* ctx,
+IceProxy::Ice::Object::begin_ice_id(const Context* ctx,
const ::IceInternal::CallbackBasePtr& del,
const ::Ice::LocalObjectPtr& cookie)
{
@@ -710,14 +710,14 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb,
Callback_Object_ice_invokePtr del;
if(dynamic_cast< ::Ice::AMISentCallback*>(cb.get()))
{
- del = newCallback_Object_ice_invoke(cb,
+ del = newCallback_Object_ice_invoke(cb,
&AMI_Object_ice_invoke::__response,
&AMI_Object_ice_invoke::__exception,
&AMI_Object_ice_invoke::__sent);
}
else
{
- del = newCallback_Object_ice_invoke(cb,
+ del = newCallback_Object_ice_invoke(cb,
&AMI_Object_ice_invoke::__response,
&AMI_Object_ice_invoke::__exception);
}
@@ -735,14 +735,14 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb,
Callback_Object_ice_invokePtr del;
if(dynamic_cast< ::Ice::AMISentCallback*>(cb.get()))
{
- del = newCallback_Object_ice_invoke(cb,
+ del = newCallback_Object_ice_invoke(cb,
&AMI_Object_ice_invoke::__response,
&AMI_Object_ice_invoke::__exception,
&AMI_Object_ice_invoke::__sent);
}
else
{
- del = newCallback_Object_ice_invoke(cb,
+ del = newCallback_Object_ice_invoke(cb,
&AMI_Object_ice_invoke::__response,
&AMI_Object_ice_invoke::__exception);
}
@@ -754,7 +754,7 @@ AsyncResultPtr
IceProxy::Ice::Object::begin_ice_invoke(const string& operation,
OperationMode mode,
const vector<Byte>& inEncaps,
- const Context* ctx,
+ const Context* ctx,
const ::IceInternal::CallbackBasePtr& del,
const ::Ice::LocalObjectPtr& cookie)
{
@@ -822,14 +822,14 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Array_Object_ice_invokePtr& cb
Callback_Object_ice_invokePtr del;
if(dynamic_cast< ::Ice::AMISentCallback*>(cb.get()))
{
- del = newCallback_Object_ice_invoke(cb,
+ del = newCallback_Object_ice_invoke(cb,
&AMI_Array_Object_ice_invoke::__response,
&AMI_Array_Object_ice_invoke::__exception,
&AMI_Array_Object_ice_invoke::__sent);
}
else
{
- del = newCallback_Object_ice_invoke(cb,
+ del = newCallback_Object_ice_invoke(cb,
&AMI_Array_Object_ice_invoke::__response,
&AMI_Array_Object_ice_invoke::__exception);
}
@@ -847,14 +847,14 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Array_Object_ice_invokePtr& cb
Callback_Object_ice_invokePtr del;
if(dynamic_cast< ::Ice::AMISentCallback*>(cb.get()))
{
- del = newCallback_Object_ice_invoke(cb,
+ del = newCallback_Object_ice_invoke(cb,
&AMI_Array_Object_ice_invoke::__response,
&AMI_Array_Object_ice_invoke::__exception,
&AMI_Array_Object_ice_invoke::__sent);
}
else
{
- del = newCallback_Object_ice_invoke(cb,
+ del = newCallback_Object_ice_invoke(cb,
&AMI_Array_Object_ice_invoke::__response,
&AMI_Array_Object_ice_invoke::__exception);
}
@@ -866,7 +866,7 @@ AsyncResultPtr
IceProxy::Ice::Object::begin_ice_invoke(const string& operation,
OperationMode mode,
const pair<const Byte*, const Byte*>& inEncaps,
- const Context* ctx,
+ const Context* ctx,
const ::IceInternal::CallbackBasePtr& del,
const ::Ice::LocalObjectPtr& cookie)
{
@@ -1021,6 +1021,12 @@ IceProxy::Ice::Object::ice_getLocatorCacheTimeout() const
ObjectPrx
IceProxy::Ice::Object::ice_locatorCacheTimeout(Int newTimeout) const
{
+ if(newTimeout < -1)
+ {
+ ostringstream s;
+ s << "invalid value passed to ice_locatorCacheTimeout: " << newTimeout;
+ throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, s.str());
+ }
if(newTimeout == _reference->getLocatorCacheTimeout())
{
return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
@@ -1214,6 +1220,12 @@ IceProxy::Ice::Object::ice_getInvocationTimeout() const
ObjectPrx
IceProxy::Ice::Object::ice_invocationTimeout(Int newTimeout) const
{
+ if(newTimeout < 1 && newTimeout != -1)
+ {
+ ostringstream s;
+ s << "invalid value passed to ice_invocationTimeout: " << newTimeout;
+ throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, s.str());
+ }
if(newTimeout == _reference->getInvocationTimeout())
{
return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
@@ -1350,6 +1362,12 @@ IceProxy::Ice::Object::ice_compress(bool b) const
ObjectPrx
IceProxy::Ice::Object::ice_timeout(int t) const
{
+ if(t < 1 && t != -1)
+ {
+ ostringstream s;
+ s << "invalid value passed to ice_timeout: " << t;
+ throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, s.str());
+ }
ReferencePtr ref = _reference->changeTimeout(t);
if(ref == _reference)
{
@@ -1457,8 +1475,8 @@ IceProxy::Ice::Object::ice_flushBatchRequests_async(const AMI_Object_ice_flushBa
Callback_Object_ice_flushBatchRequestsPtr __del;
if(dynamic_cast< AMISentCallback*>(cb.get()))
{
- __del = newCallback_Object_ice_flushBatchRequests(cb,
- &AMI_Object_ice_flushBatchRequests::__exception,
+ __del = newCallback_Object_ice_flushBatchRequests(cb,
+ &AMI_Object_ice_flushBatchRequests::__exception,
&AMI_Object_ice_flushBatchRequests::__sent);
}
else
@@ -1473,7 +1491,7 @@ IceProxy::Ice::Object::ice_flushBatchRequests_async(const AMI_Object_ice_flushBa
IceProxy::Ice::Object::begin_ice_flushBatchRequestsInternal(const ::IceInternal::CallbackBasePtr& del,
const ::Ice::LocalObjectPtr& cookie)
{
- ::IceInternal::ProxyBatchOutgoingAsyncPtr __result =
+ ::IceInternal::ProxyBatchOutgoingAsyncPtr __result =
new ::IceInternal::ProxyBatchOutgoingAsync(this, ice_flushBatchRequests_name, del, cookie);
try
{
@@ -1508,14 +1526,14 @@ IceProxy::Ice::Object::__copyFrom(const ObjectPrx& from)
}
int
-IceProxy::Ice::Object::__handleException(const Exception& ex,
- const RequestHandlerPtr& handler,
+IceProxy::Ice::Object::__handleException(const Exception& ex,
+ const RequestHandlerPtr& handler,
OperationMode mode,
bool sent,
int& cnt)
{
__setRequestHandler(handler, 0); // Clear the request handler
-
+
//
// We only retry local exception, system exceptions aren't retried.
//
@@ -1528,7 +1546,7 @@ IceProxy::Ice::Object::__handleException(const Exception& ex,
// "at-most-once" (see the implementation of the checkRetryAfterException method
// of the ProxyFactory class for the reasons why it can be useful).
//
- // If the request didn't get sent or if it's non-mutating or idempotent it can
+ // If the request didn't get sent or if it's non-mutating or idempotent it can
// also always be retried if the retry count isn't reached.
//
const LocalException* localEx = dynamic_cast<const LocalException*>(&ex);
@@ -1578,8 +1596,8 @@ IceProxy::Ice::Object::__checkAsyncTwowayOnly(const string& name) const
//
if(!ice_isTwoway())
{
- throw IceUtil::IllegalArgumentException(__FILE__,
- __LINE__,
+ throw IceUtil::IllegalArgumentException(__FILE__,
+ __LINE__,
"`" + name + "' can only be called with a twoway proxy");
}
}
@@ -1804,7 +1822,7 @@ Ice::proxyIdentityAndFacetLess(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
Identity lhsIdentity = lhs->ice_getIdentity();
Identity rhsIdentity = rhs->ice_getIdentity();
-
+
if(lhsIdentity < rhsIdentity)
{
return true;
@@ -1813,10 +1831,10 @@ Ice::proxyIdentityAndFacetLess(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
return false;
}
-
+
string lhsFacet = lhs->ice_getFacet();
string rhsFacet = rhs->ice_getFacet();
-
+
if(lhsFacet < rhsFacet)
{
return true;
@@ -1825,7 +1843,7 @@ Ice::proxyIdentityAndFacetLess(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
return false;
}
-
+
return false;
}
}
@@ -1849,18 +1867,18 @@ Ice::proxyIdentityAndFacetEqual(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
Identity lhsIdentity = lhs->ice_getIdentity();
Identity rhsIdentity = rhs->ice_getIdentity();
-
+
if(lhsIdentity == rhsIdentity)
{
string lhsFacet = lhs->ice_getFacet();
string rhsFacet = rhs->ice_getFacet();
-
+
if(lhsFacet == rhsFacet)
{
return true;
}
}
-
+
return false;
}
}
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp
index 7df03d0c246..0e8329b0f1b 100644
--- a/cpp/src/Ice/ReferenceFactory.cpp
+++ b/cpp/src/Ice/ReferenceFactory.cpp
@@ -55,7 +55,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
return 0;
}
- return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(),
+ return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(),
endpoints, "", "");
}
@@ -70,7 +70,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
return 0;
}
- return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(),
+ return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(),
vector<EndpointIPtr>(), adapterId, "");
}
@@ -85,9 +85,9 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const Ice::Connecti
//
// Create new reference
//
- return new FixedReference(_instance,
- _communicator,
- ident,
+ return new FixedReference(_instance,
+ _communicator,
+ ident,
"", // Facet
connection->endpoint()->datagram() ? Reference::ModeDatagram : Reference::ModeTwoway,
connection->endpoint()->secure(),
@@ -116,7 +116,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
ex.str = "no non-whitespace characters found in `" + s + "'";
throw ex;
}
-
+
//
// Extract the identity, which may be enclosed in single
// or double quotation marks.
@@ -205,7 +205,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
{
break;
}
-
+
end = s.find_first_of(delim + ":@", beg);
if(end == string::npos)
{
@@ -216,7 +216,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
{
break;
}
-
+
string option = s.substr(beg, end - beg);
if(option.length() != 2 || option[0] != '-')
{
@@ -372,7 +372,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
ex.str = "no argument provided for -e option in `" + s + "'";
throw ex;
}
-
+
try
{
encoding = Ice::stringToEncodingVersion(argument);
@@ -394,7 +394,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
ex.str = "no argument provided for -p option in `" + s + "'";
throw ex;
}
-
+
try
{
protocol = Ice::stringToProtocolVersion(argument);
@@ -429,11 +429,11 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
{
vector<string> unknownEndpoints;
end = beg;
-
+
while(end < s.length() && s[end] == ':')
{
beg = end + 1;
-
+
end = beg;
while(true)
{
@@ -476,7 +476,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
++end;
}
}
-
+
string es = s.substr(beg, end - beg);
EndpointIPtr endp = _instance->endpointFactoryManager()->create(es, false);
if(endp != 0)
@@ -641,7 +641,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
string adapterId;
Ice::Int sz = s->readSize();
-
+
if(sz > 0)
{
endpoints.reserve(sz);
@@ -843,7 +843,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
routerInfo = _instance->routerManager()->get(router);
}
}
-
+
property = propertyPrefix + ".CollocationOptimized";
collocationOptimized = properties->getPropertyAsIntWithDefault(property, collocationOptimized) > 0;
@@ -860,7 +860,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
if(type == "Random")
{
endpointSelection = Random;
- }
+ }
else if(type == "Ordered")
{
endpointSelection = Ordered;
@@ -872,25 +872,49 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
throw ex;
}
}
-
+
property = propertyPrefix + ".LocatorCacheTimeout";
- locatorCacheTimeout = properties->getPropertyAsIntWithDefault(property, locatorCacheTimeout);
+ string value = properties->getProperty(property);
+ if(!value.empty())
+ {
+ locatorCacheTimeout = properties->getPropertyAsIntWithDefault(property, locatorCacheTimeout);
+ if(locatorCacheTimeout < -1)
+ {
+ locatorCacheTimeout = -1;
+
+ Warning out(_instance->initializationData().logger);
+ out << "invalid value for " << property << "`" << properties->getProperty(property) << "'"
+ << ": defaulting to -1";
+ }
+ }
property = propertyPrefix + ".InvocationTimeout";
- invocationTimeout = properties->getPropertyAsIntWithDefault(property, invocationTimeout);
+ value = properties->getProperty(property);
+ if(!value.empty())
+ {
+ invocationTimeout = properties->getPropertyAsIntWithDefault(property, invocationTimeout);
+ if(invocationTimeout < 1 && invocationTimeout != -1)
+ {
+ invocationTimeout = -1;
+
+ Warning out(_instance->initializationData().logger);
+ out << "invalid value for " << property << "`" << properties->getProperty(property) << "'"
+ << ": defaulting to -1";
+ }
+ }
property = propertyPrefix + ".Context.";
PropertyDict contexts = properties->getPropertiesForPrefix(property);
for(PropertyDict::const_iterator p = contexts.begin(); p != contexts.end(); ++p)
{
- ctx.insert(make_pair(p->first.substr(property.length()), p->second));
+ ctx.insert(make_pair(p->first.substr(property.length()), p->second));
}
}
//
// Create new reference
//
- return new RoutableReference(_instance,
+ return new RoutableReference(_instance,
_communicator,
ident,
facet,
diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp
index 34754f816b7..ce615ab82d8 100644
--- a/cpp/test/Ice/proxy/AllTests.cpp
+++ b/cpp/test/Ice/proxy/AllTests.cpp
@@ -461,6 +461,88 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(base->ice_encodingVersion(Ice::Encoding_1_0)->ice_getEncodingVersion() == Ice::Encoding_1_0);
test(base->ice_encodingVersion(Ice::Encoding_1_1)->ice_getEncodingVersion() == Ice::Encoding_1_1);
test(base->ice_encodingVersion(Ice::Encoding_1_0)->ice_getEncodingVersion() != Ice::Encoding_1_1);
+
+ try
+ {
+ base->ice_timeout(0);
+ test(false);
+ }
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ }
+
+ try
+ {
+ base->ice_timeout(-1);
+ }
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ test(false);
+ }
+
+ try
+ {
+ base->ice_timeout(-2);
+ test(false);
+ }
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ }
+
+ try
+ {
+ base->ice_invocationTimeout(0);
+ test(false);
+ }
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ }
+
+ try
+ {
+ base->ice_invocationTimeout(-1);
+ }
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ test(false);
+ }
+
+ try
+ {
+ base->ice_invocationTimeout(-2);
+ test(false);
+ }
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ }
+
+ try
+ {
+ base->ice_locatorCacheTimeout(0);
+ }
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ test(false);
+ }
+
+ try
+ {
+ base->ice_locatorCacheTimeout(-1);
+ }
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ test(false);
+ }
+
+ try
+ {
+ base->ice_locatorCacheTimeout(-2);
+ test(false);
+ }
+ catch(const IceUtil::IllegalArgumentException&)
+ {
+ }
+
cout << "ok" << endl;
cout << "testing proxy comparison... " << flush;