diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2014-08-19 13:10:29 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2014-08-19 13:10:29 -0230 |
commit | c6d20e1e1afc75f8bd889c093ccbffb247ec30cb (patch) | |
tree | 19443a7e7263ce1d715dad261b4574942c419552 | |
parent | Fixed (ICE-5592) - Add IceSSL.FindCert for OS X and Windows (diff) | |
download | ice-c6d20e1e1afc75f8bd889c093ccbffb247ec30cb.tar.bz2 ice-c6d20e1e1afc75f8bd889c093ccbffb247ec30cb.tar.xz ice-c6d20e1e1afc75f8bd889c093ccbffb247ec30cb.zip |
ICE-3492 handle improper settings for timeout values
29 files changed, 1275 insertions, 402 deletions
diff --git a/allTests.py b/allTests.py index dce0190bc35..4bf2a2a1715 100755 --- a/allTests.py +++ b/allTests.py @@ -15,7 +15,7 @@ import TestUtil testGroups = [] -for d in [ "cpp", "java", "cs", "py", "rb", "php" ]: +for d in [ "cpp", "java", "cs", "py", "rb", "php", "js" ]: filename = os.path.abspath(os.path.join(os.path.dirname(__file__), d, "allTests.py")) f = open(filename, "r") 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; diff --git a/cs/src/Ice/DefaultsAndOverrides.cs b/cs/src/Ice/DefaultsAndOverrides.cs index 89aee4963c6..97794755009 100644 --- a/cs/src/Ice/DefaultsAndOverrides.cs +++ b/cs/src/Ice/DefaultsAndOverrides.cs @@ -9,13 +9,14 @@ using System; using System.Net; +using System.Text; namespace IceInternal { public sealed class DefaultsAndOverrides { - internal DefaultsAndOverrides(Ice.Properties properties) + internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger) { string val; @@ -51,6 +52,14 @@ namespace IceInternal { overrideTimeout = true; overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout"); + if(overrideTimeoutValue < 1 && overrideTimeoutValue != -1) + { + overrideTimeoutValue = -1; + StringBuilder msg = new StringBuilder("invalid value for Ice.Override.Timeout `"); + msg.Append(properties.getProperty("Ice.Override.Timeout")); + msg.Append("': defaulting to -1"); + logger.warning(msg.ToString()); + } } else { @@ -63,6 +72,14 @@ namespace IceInternal { overrideConnectTimeout = true; overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout"); + if(overrideConnectTimeoutValue < 1 && overrideConnectTimeoutValue != -1) + { + overrideConnectTimeoutValue = -1; + StringBuilder msg = new StringBuilder("invalid value for Ice.Override.ConnectTimeout `"); + msg.Append(properties.getProperty("Ice.Override.ConnectTimeout")); + msg.Append("': defaulting to -1"); + logger.warning(msg.ToString()); + } } else { @@ -75,6 +92,14 @@ namespace IceInternal { overrideCloseTimeout = true; overrideCloseTimeoutValue = properties.getPropertyAsInt("Ice.Override.CloseTimeout"); + if(overrideCloseTimeoutValue < 1 && overrideCloseTimeoutValue != -1) + { + overrideCloseTimeoutValue = -1; + StringBuilder msg = new StringBuilder("invalid value for Ice.Override.CloseTimeout `"); + msg.Append(properties.getProperty("Ice.Override.CloseTimeout")); + msg.Append("': defaulting to -1"); + logger.warning(msg.ToString()); + } } else { @@ -139,11 +164,32 @@ namespace IceInternal 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") + "'"); + defaultTimeout = 60000; + StringBuilder msg = new StringBuilder("invalid value for Ice.Default.Timeout `"); + msg.Append(properties.getProperty("Ice.Default.Timeout")); + msg.Append("': defaulting to 60000"); + logger.warning(msg.ToString()); } + defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1); + if(defaultLocatorCacheTimeout < -1) + { + defaultLocatorCacheTimeout = -1; + StringBuilder msg = new StringBuilder("invalid value for Ice.Default.LocatorCacheTimeout `"); + msg.Append(properties.getProperty("Ice.Default.LocatorCacheTimeout")); + msg.Append("': defaulting to -1"); + logger.warning(msg.ToString()); + } + defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1); + if(defaultInvocationTimeout < 1 && defaultInvocationTimeout != -1) + { + defaultInvocationTimeout = -1; + StringBuilder msg = new StringBuilder("invalid value for Ice.Default.InvocationTimeout `"); + msg.Append(properties.getProperty("Ice.Default.InvocationTimeout")); + msg.Append("': defaulting to -1"); + logger.warning(msg.ToString()); + } defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0; diff --git a/cs/src/Ice/Instance.cs b/cs/src/Ice/Instance.cs index 9aa638e3a32..ac6962b26f4 100644 --- a/cs/src/Ice/Instance.cs +++ b/cs/src/Ice/Instance.cs @@ -755,12 +755,12 @@ namespace IceInternal _traceLevels = new TraceLevels(_initData.properties); - _defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties); + _defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties, _initData.logger); _clientACM = new ACMConfig(_initData.properties, _initData.logger, "Ice.ACM.Client", - new ACMConfig(_initData.properties, _initData.logger, "Ice.ACM", + new ACMConfig(_initData.properties, _initData.logger, "Ice.ACM", new ACMConfig(false))); _serverACM = new ACMConfig(_initData.properties, @@ -840,14 +840,14 @@ namespace IceInternal 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"); - _endpointFactoryManager.add(new WSEndpointFactory(wsProtocolInstance, + _endpointFactoryManager.add(new WSEndpointFactory(wsProtocolInstance, tcpEndpointFactory.clone(wsProtocolInstance))); #if !SILVERLIGHT @@ -1074,7 +1074,7 @@ namespace IceInternal { _retryQueue.destroy(); } - + if(_observer != null) { _observer.setObserverUpdater(null); diff --git a/cs/src/Ice/Proxy.cs b/cs/src/Ice/Proxy.cs index 2b2687b6314..7c57278e720 100644 --- a/cs/src/Ice/Proxy.cs +++ b/cs/src/Ice/Proxy.cs @@ -1678,6 +1678,10 @@ namespace Ice /// <param name="newTimeout">The new locator cache timeout (in seconds).</param> public ObjectPrx ice_locatorCacheTimeout(int newTimeout) { + if(newTimeout < -1) + { + throw new System.ArgumentException("invalid value passed to ice_locatorCacheTimeout: " + newTimeout); + } if(newTimeout == _reference.getLocatorCacheTimeout()) { return this; @@ -1703,6 +1707,10 @@ namespace Ice /// <param name="newTimeout">The new invocation timeout (in seconds).</param> public ObjectPrx ice_invocationTimeout(int newTimeout) { + if(newTimeout < 1 && newTimeout != -1) + { + throw new System.ArgumentException("invalid value passed to ice_invocationTimeout: " + newTimeout); + } if(newTimeout == _reference.getInvocationTimeout()) { return this; @@ -2080,6 +2088,10 @@ namespace Ice /// <returns>A new proxy with the specified timeout.</returns> public ObjectPrx ice_timeout(int t) { + if(t < 1 && t != -1) + { + throw new System.ArgumentException("invalid value passed to ice_timeout: " + t); + } IceInternal.Reference @ref = _reference.changeTimeout(t); if(@ref.Equals(_reference)) { @@ -2345,7 +2357,7 @@ namespace Ice // "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. // if(ex is LocalException && (!sent || @@ -2424,7 +2436,7 @@ namespace Ice og__.readEmptyParams(); } } - + public void end__(AsyncResult result, string operation) { IceInternal.OutgoingAsync outAsync = (IceInternal.OutgoingAsync)result; @@ -2546,7 +2558,7 @@ namespace Ice return proxy; } - protected IceInternal.Outgoing getOutgoing(String operation, OperationMode mode, + protected IceInternal.Outgoing getOutgoing(String operation, OperationMode mode, Dictionary<string, string> context, bool explicitCtx) { IceInternal.Outgoing @out = null; @@ -2572,7 +2584,7 @@ namespace Ice } return @out; } - + protected void reclaimOutgoing(IceInternal.Outgoing @out) { @out.detach(); @@ -2583,7 +2595,7 @@ namespace Ice // Clear references to Ice objects as soon as possible. // @out.reclaim(); - + lock(this) { @out.next = _outgoingCache; @@ -2591,7 +2603,7 @@ namespace Ice } } } - + private IceInternal.Reference _reference; private IceInternal.RequestHandler _requestHandler; private IceInternal.Outgoing _outgoingCache; diff --git a/cs/src/Ice/ReferenceFactory.cs b/cs/src/Ice/ReferenceFactory.cs index 05be7eb238b..76455a4011d 100644 --- a/cs/src/Ice/ReferenceFactory.cs +++ b/cs/src/Ice/ReferenceFactory.cs @@ -38,7 +38,7 @@ namespace IceInternal { return null; } - + // // Create new reference // @@ -52,13 +52,13 @@ namespace IceInternal { return null; } - + // // Create new reference // return new FixedReference( - instance_, - _communicator, + instance_, + _communicator, ident, "", // Facet connection.endpoint().datagram() ? Reference.Mode.ModeDatagram : Reference.Mode.ModeTwoway, @@ -350,7 +350,7 @@ namespace IceInternal { throw new Ice.ProxyParseException("no argument provided for -e option `" + s + "'"); } - + try { encoding = Ice.Util.stringToEncodingVersion(argument); @@ -369,7 +369,7 @@ namespace IceInternal { throw new Ice.ProxyParseException("no argument provided for -p option `" + s + "'"); } - + try { protocol = Ice.Util.stringToProtocolVersion(argument); @@ -406,7 +406,7 @@ namespace IceInternal while(end < s.Length && s[end] == ':') { beg = end + 1; - + end = beg; while(true) { @@ -449,7 +449,7 @@ namespace IceInternal ++end; } } - + string es = s.Substring(beg, end - beg); EndpointI endp = instance_.endpointFactoryManager().create(es, false); if(endp != null) @@ -620,7 +620,7 @@ namespace IceInternal { adapterId = s.readString(); } - + return create(ident, facet, (Reference.Mode)mode, secure, protocol, encoding, endpoints, adapterId, null); } @@ -630,7 +630,7 @@ namespace IceInternal { return this; } - + ReferenceFactory factory = new ReferenceFactory(instance_, _communicator); factory._defaultLocator = _defaultLocator; factory._defaultRouter = defaultRouter; @@ -648,7 +648,7 @@ namespace IceInternal { return this; } - + ReferenceFactory factory = new ReferenceFactory(instance_, _communicator); factory._defaultLocator = defaultLocator; factory._defaultRouter = _defaultRouter; @@ -768,7 +768,7 @@ namespace IceInternal int locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout; int invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout; Dictionary<string, string> context = null; - + // // Override the defaults with the proxy properties if a property prefix is defined. // @@ -783,9 +783,9 @@ namespace IceInternal { checkForUnknownProperties(propertyPrefix); } - + string property; - + property = propertyPrefix + ".Locator"; Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)); if(locator != null) @@ -816,7 +816,7 @@ namespace IceInternal routerInfo = instance_.routerManager().get(router); } } - + property = propertyPrefix + ".CollocationOptimized"; collocOptimized = properties.getPropertyAsIntWithDefault(property, collocOptimized ? 1 : 0) > 0; @@ -833,7 +833,7 @@ namespace IceInternal if(type.Equals("Random")) { endpointSelection = Ice.EndpointSelectionType.Random; - } + } else if(type.Equals("Ordered")) { endpointSelection = Ice.EndpointSelectionType.Ordered; @@ -844,12 +844,42 @@ namespace IceInternal "'; expected `Random' or `Ordered'"); } } - + property = propertyPrefix + ".LocatorCacheTimeout"; - locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout); + string val = properties.getProperty(property); + if(val.Length > 0) + { + locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout); + if(locatorCacheTimeout < -1) + { + locatorCacheTimeout = -1; + + StringBuilder msg = new StringBuilder("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); + val = properties.getProperty(property); + if(val.Length > 0) + { + invocationTimeout = properties.getPropertyAsIntWithDefault(property, invocationTimeout); + if(invocationTimeout < 1 && invocationTimeout != -1) + { + invocationTimeout = -1; + + StringBuilder msg = new StringBuilder("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."; Dictionary<string, string> contexts = properties.getPropertiesForPrefix(property); @@ -858,15 +888,15 @@ namespace IceInternal context = new Dictionary<string, string>(); foreach(KeyValuePair<string, string> e in contexts) { - context.Add(e.Key.Substring(property.Length), e.Value); + context.Add(e.Key.Substring(property.Length), e.Value); } } } - + // // Create new reference // - return new RoutableReference(instance_, + return new RoutableReference(instance_, _communicator, ident, facet, diff --git a/cs/test/Ice/proxy/AllTests.cs b/cs/test/Ice/proxy/AllTests.cs index 8f247ededee..557b8398871 100644 --- a/cs/test/Ice/proxy/AllTests.cs +++ b/cs/test/Ice/proxy/AllTests.cs @@ -475,6 +475,89 @@ public class AllTests : TestCommon.TestApp test(!baseProxy.ice_collocationOptimized(false).ice_isCollocationOptimized()); test(baseProxy.ice_preferSecure(true).ice_isPreferSecure()); test(!baseProxy.ice_preferSecure(false).ice_isPreferSecure()); + + try + { + baseProxy.ice_timeout(0); + test(false); + } + catch(System.ArgumentException) + { + } + + try + { + baseProxy.ice_timeout(-1); + } + catch(System.ArgumentException) + { + test(false); + } + + try + { + baseProxy.ice_timeout(-2); + test(false); + } + catch(System.ArgumentException) + { + } + + try + { + baseProxy.ice_invocationTimeout(0); + test(false); + } + catch(System.ArgumentException) + { + } + + try + { + baseProxy.ice_invocationTimeout(-1); + } + catch(System.ArgumentException) + { + test(false); + } + + try + { + baseProxy.ice_invocationTimeout(-2); + test(false); + } + catch(System.ArgumentException) + { + } + + try + { + baseProxy.ice_locatorCacheTimeout(0); + } + catch(System.ArgumentException) + { + test(false); + } + + try + { + baseProxy.ice_locatorCacheTimeout(-1); + } + catch(System.ArgumentException) + { + test(false); + } + + try + { + baseProxy.ice_locatorCacheTimeout(-2); + test(false); + } + catch(System.ArgumentException) + { + } + + WriteLine("ok"); Write("testing proxy comparison... "); 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); diff --git a/java/test/Ice/proxy/AllTests.java b/java/test/Ice/proxy/AllTests.java index 959caa610b0..45dfbe901ed 100644 --- a/java/test/Ice/proxy/AllTests.java +++ b/java/test/Ice/proxy/AllTests.java @@ -479,6 +479,88 @@ public class AllTests test(base.ice_encodingVersion(Ice.Util.Encoding_1_0).ice_getEncodingVersion().equals(Ice.Util.Encoding_1_0)); test(base.ice_encodingVersion(Ice.Util.Encoding_1_1).ice_getEncodingVersion().equals(Ice.Util.Encoding_1_1)); test(!base.ice_encodingVersion(Ice.Util.Encoding_1_0).ice_getEncodingVersion().equals(Ice.Util.Encoding_1_1)); + + try + { + base.ice_timeout(0); + test(false); + } + catch(IllegalArgumentException e) + { + } + + try + { + base.ice_timeout(-1); + } + catch(IllegalArgumentException e) + { + test(false); + } + + try + { + base.ice_timeout(-2); + test(false); + } + catch(IllegalArgumentException e) + { + } + + try + { + base.ice_invocationTimeout(0); + test(false); + } + catch(IllegalArgumentException e) + { + } + + try + { + base.ice_invocationTimeout(-1); + } + catch(IllegalArgumentException e) + { + test(false); + } + + try + { + base.ice_invocationTimeout(-2); + test(false); + } + catch(IllegalArgumentException e) + { + } + + try + { + base.ice_locatorCacheTimeout(0); + } + catch(IllegalArgumentException e) + { + test(false); + } + + try + { + base.ice_locatorCacheTimeout(-1); + } + catch(IllegalArgumentException e) + { + test(false); + } + + try + { + base.ice_locatorCacheTimeout(-2); + test(false); + } + catch(IllegalArgumentException e) + { + } + out.println("ok"); out.print("testing proxy comparison... "); diff --git a/js/src/Ice/DefaultsAndOverrides.js b/js/src/Ice/DefaultsAndOverrides.js index 521c5a7d703..e7b224f2650 100644 --- a/js/src/Ice/DefaultsAndOverrides.js +++ b/js/src/Ice/DefaultsAndOverrides.js @@ -12,28 +12,40 @@ require("Ice/EndpointTypes"); require("Ice/Protocol"); require("Ice/LocalException"); - + var Ice = global.Ice || {}; - + var FormatType = Ice.FormatType; var EndpointSelectionType = Ice.EndpointSelectionType; var Protocol = Ice.Protocol; - var DefaultsAndOverrides = function(properties) + var DefaultsAndOverrides = function(properties, logger) { var value; - - this.defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol", + + this.defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol", Ice.TcpEndpointFactory !== undefined ? "tcp" : "ws"); value = properties.getProperty("Ice.Default.Host"); this.defaultHost = value.length > 0 ? value : null; + value = properties.getProperty("Ice.Default.SourceAddress"); + if(value.length > 0) + { + logger.warning("Ice.Default.SourceAddress property is not supported in this language"); + } + value = properties.getProperty("Ice.Override.Timeout"); if(value.length > 0) { this.overrideTimeout = true; this.overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout"); + if(this.overrideTimeoutValue < 1 && this.overrideTimeoutValue !== -1) + { + this.overrideTimeoutValue = -1; + logger.warning("invalid value for Ice.Override.Timeout `" + + properties.getProperty("Ice.Override.Timeout") + "': defaulting to -1"); + } } else { @@ -46,6 +58,12 @@ { this.overrideConnectTimeout = true; this.overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout"); + if(this.overrideConnectTimeoutValue < 1 && this.overrideConnectTimeoutValue !== -1) + { + this.overrideConnectTimeoutValue = -1; + logger.warning("invalid value for Ice.Override.ConnectTimeout `" + + properties.getProperty("Ice.Override.ConnectTimeout") + "': defaulting to -1"); + } } else { @@ -58,6 +76,12 @@ { this.overrideCloseTimeout = true; this.overrideCloseTimeoutValue = properties.getPropertyAsInt("Ice.Override.CloseTimeout"); + if(this.overrideCloseTimeoutValue < 1 && this.overrideCloseTimeoutValue !== -1) + { + this.overrideCloseTimeoutValue = -1; + logger.warning("invalid value for Ice.Override.CloseTimeout `" + + properties.getProperty("Ice.Override.CloseTimeout") + "': defaulting to -1"); + } } else { @@ -84,8 +108,29 @@ throw ex; } + this.defaultTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000); + if(this.defaultTimeout < 1 && this.defaultTimeout !== -1) + { + this.defaultTimeout = 60000; + logger.warning("invalid value for Ice.Default.Timeout `" + properties.getProperty("Ice.Default.Timeout") + + "': defaulting to 60000"); + } + this.defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1); + if(this.defaultLocatorCacheTimeout < -1) + { + this.defaultLocatorCacheTimeout = -1; + logger.warning("invalid value for Ice.Default.LocatorCacheTimeout `" + + properties.getProperty("Ice.Default.LocatorCacheTimeout") + "': defaulting to -1"); + } + this.defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1); + if(this.defaultInvocationTimeout < 1 && this.defaultInvocationTimeout !== -1) + { + this.defaultInvocationTimeout = -1; + logger.warning("invalid value for Ice.Default.InvocationTimeout `" + + properties.getProperty("Ice.Default.InvocationTimeout") + "': defaulting to -1"); + } this.defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0; diff --git a/js/src/Ice/Instance.js b/js/src/Ice/Instance.js index 12f875b9f3c..0f7b1a8ff27 100644 --- a/js/src/Ice/Instance.js +++ b/js/src/Ice/Instance.js @@ -297,8 +297,8 @@ } this._traceLevels = new TraceLevels(this._initData.properties); - - this._defaultsAndOverrides = new DefaultsAndOverrides(this._initData.properties); + + this._defaultsAndOverrides = new DefaultsAndOverrides(this._initData.properties, this._initData.logger); var defMessageSizeMax = 1024; var num = this._initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defMessageSizeMax); @@ -318,8 +318,8 @@ this._clientACM = new ACMConfig(this._initData.properties, this._initData.logger, "Ice.ACM.Client", new ACMConfig(this._initData.properties, this._initData.logger, "Ice.ACM", new ACMConfig())); - - this._implicitContext = + + this._implicitContext = ImplicitContextI.create(this._initData.properties.getProperty("Ice.ImplicitContext")); this._routerManager = new RouterManager(); @@ -336,7 +336,7 @@ { this._endpointFactoryManager.add(new Ice.TcpEndpointFactory(this)); } - + if(typeof(Ice.WSEndpointFactory) !== "undefined") { this._endpointFactoryManager.add(new Ice.WSEndpointFactory(this, false)); @@ -422,7 +422,7 @@ // ObjectAdapterI::deactivate() will cause an exception. // this._state = StateDestroyInProgress; - + var self = this; Ice.Promise.try( function() @@ -533,7 +533,7 @@ return promise; }, }); - + Ice.Instance = Instance; global.Ice = Ice; }(typeof (global) === "undefined" ? window : global)); diff --git a/js/src/Ice/ObjectPrx.js b/js/src/Ice/ObjectPrx.js index 3d09667485a..97149b2dd96 100644 --- a/js/src/Ice/ObjectPrx.js +++ b/js/src/Ice/ObjectPrx.js @@ -157,6 +157,10 @@ }, ice_locatorCacheTimeout: function(newTimeout) { + if(newTimeout < -1) + { + throw new Error("invalid value passed to ice_locatorCacheTimeout: " + newTimeout); + } if(newTimeout === this._reference.getLocatorCacheTimeout()) { return this; @@ -172,6 +176,10 @@ }, ice_invocationTimeout: function(newTimeout) { + if(newTimeout < 1 && newTimeout !== -1) + { + throw new Error("invalid value passed to ice_invocationTimeout: " + newTimeout); + } if(newTimeout === this._reference.getInvocationTimeout()) { return this; @@ -379,6 +387,10 @@ }, ice_timeout: function(t) { + if(t < 1 && t !== -1) + { + throw new Error("invalid value passed to ice_timeout: " + t); + } var ref = this._reference.changeTimeout(t); if(ref.equals(this._reference)) { @@ -477,19 +489,19 @@ // "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. // - if(ex instanceof Ice.LocalException && + if(ex instanceof Ice.LocalException && (!sent || mode == OperationMode.Nonmutating || mode == OperationMode.Idempotent || ex instanceof Ice.CloseConnectionException || ex instanceof Ice.ObjectNotExistException)) { try { - return this._reference.getInstance().proxyFactory().checkRetryAfterException(ex, + return this._reference.getInstance().proxyFactory().checkRetryAfterException(ex, this._reference, - sleep, + sleep, cnt); } catch(exc) diff --git a/js/src/Ice/Reference.js b/js/src/Ice/Reference.js index ed91637cefc..1253abf1eaf 100644 --- a/js/src/Ice/Reference.js +++ b/js/src/Ice/Reference.js @@ -27,9 +27,9 @@ require("Ice/LocalException"); require("Ice/Version"); require("Ice/PropertyNames"); - + var Ice = global.Ice || {}; - + var ArrayUtil = Ice.ArrayUtil; var Debug = Ice.Debug; var HashMap = Ice.HashMap; @@ -46,9 +46,9 @@ var RouterPrx = Ice.RouterPrx; var LocatorPrx = Ice.LocatorPrx; var PropertyNames = Ice.PropertyNames; - + var Class = Ice.Class; - + var suffixes = [ "EndpointSelection", @@ -61,7 +61,7 @@ "Router", "CollocationOptimized" ]; - + // // Only for use by Instance // @@ -609,7 +609,7 @@ protocol = Ice.Protocol_1_0; encoding = Ice.Encoding_1_0; } - + var endpoints = null; // EndpointI[] var adapterId = null; @@ -809,10 +809,32 @@ } property = propertyPrefix + ".LocatorCacheTimeout"; - locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout); + var value = properties.getProperty(property); + if(value.length !== 0) + { + locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout); + if(locatorCacheTimeout < -1) + { + locatorCacheTimeout = -1; + var s = "invalid value for" + property + "`" + properties.getProperty(property) + + "': defaulting to -1"; + this._instance.initializationData().logger.warning(s); + } + } property = propertyPrefix + ".InvocationTimeout"; - invocationTimeout = properties.getPropertyAsIntWithDefault(property, invocationTimeout); + value = properties.getProperty(property); + if(value.length !== 0) + { + invocationTimeout = properties.getPropertyAsIntWithDefault(property, invocationTimeout); + if(invocationTimeout < 1 && invocationTimeout !== -1) + { + invocationTimeout = -1; + var s = "invalid value for" + property + "`" + properties.getProperty(property) + + "': defaulting to -1"; + this._instance.initializationData().logger.warning(s); + } + } } // @@ -837,9 +859,9 @@ invocationTimeout); } }); - + Ice.ReferenceFactory = ReferenceFactory; - + var Reference = Class({ __init__: function(instance, communicator, identity, facet, mode, secure, protocol, encoding, invocationTimeout) { @@ -1396,7 +1418,7 @@ r._compress = this._compress; } }); - + Reference._emptyContext = new HashMap(); Reference._emptyEndpoints = []; @@ -1612,7 +1634,7 @@ adapterId, locatorInfo, routerInfo, cacheConnection, preferSecure, endpointSelection, locatorCacheTimeout, invocationTimeout) { - Reference.call(this, instance, communicator, identity, facet, mode, secure, protocol, encoding, + Reference.call(this, instance, communicator, identity, facet, mode, secure, protocol, encoding, invocationTimeout); this._endpoints = endpoints; this._adapterId = adapterId; @@ -2124,11 +2146,11 @@ }, clone: function() { - var r = new RoutableReference(this.getInstance(), - this.getCommunicator(), - this.getIdentity(), + var r = new RoutableReference(this.getInstance(), + this.getCommunicator(), + this.getIdentity(), this.getFacet(), - this.getMode(), + this.getMode(), this.getSecure(), this.getProtocol(), this.getEncoding(), @@ -2330,10 +2352,10 @@ return promise; } }); - + Ice.RoutableReference = RoutableReference; global.Ice = Ice; - + var CreateConnectionCallback = Class({ __init__: function(r, endpoints, promise) { diff --git a/js/src/Ice/TcpEndpointI.js b/js/src/Ice/TcpEndpointI.js index 97851850877..aea7ac9d963 100644 --- a/js/src/Ice/TcpEndpointI.js +++ b/js/src/Ice/TcpEndpointI.js @@ -25,11 +25,12 @@ var Class = Ice.Class; var TcpEndpointI = Class(Ice.Endpoint, { - __init__: function(instance, ho, po, ti, conId, co) + __init__: function(instance, ho, po, sif, ti, conId, co) { this._instance = instance; this._host = ho; this._port = po; + this._sourceAddress = sif; this._timeout = ti; this._connectionId = conId; this._compress = co; @@ -66,10 +67,20 @@ s += " -p " + this._port; - if(this._timeout != -1) + if(this._sourceAddress.length > 0) + { + s += " --sourceAddress " + this._sourceAddress; + } + + if(this._timeout == -1) + { + s += " -t infinite"; + } + else { s += " -t " + this._timeout; } + if(this._compress) { s += " -z"; @@ -81,7 +92,7 @@ // getInfo: function() { - return new TCPEndpointInfoI(this._timeout, this._compress, this._host, this._port); + return new TCPEndpointInfoI(this._timeout, this._compress, this._host, this._port, this._sourceAddress); }, // // Marshal the endpoint @@ -124,8 +135,8 @@ } else { - return new TcpEndpointI(this._instance, this._host, this._port, timeout, this._connectionId, - this._compress); + return new TcpEndpointI(this._instance, this._host, this._port, this._sourceAddress, timeout, + this._connectionId, this._compress); } }, // @@ -139,8 +150,8 @@ } else { - return new TcpEndpointI(this._instance, this._host, this._port, this._timeout, connectionId, - this._compress); + return new TcpEndpointI(this._instance, this._host, this._port, this._sourceAddress, this._timeout, + connectionId, this._compress); } }, // @@ -164,8 +175,8 @@ } else { - return new TcpEndpointI(this._instance, this._host, this._port, this._timeout, this._connectionId, - compress); + return new TcpEndpointI(this._instance, this._host, this._port, this._sourceAddress, this._timeout, + this._connectionId, compress); } }, // @@ -320,12 +331,13 @@ this._hashCode = h; } }); - + TcpEndpointI.fromString = function(instance, str, oaEndpoint) { var host = null; var port = 0; - var timeout = -1; + var sourceAddress = ""; + var timeout = -2; var compress = false; var arr = str.split(/[ \t\n\r]+/); @@ -340,12 +352,6 @@ } var option = arr[i++]; - if(option.length != 2 && option.charAt(0) != '-') - { - throw new Ice.EndpointParseException("expected an endpoint option but found `" + option + - "' in endpoint `tcp " + str + "'"); - } - var argument = null; if(i < arr.length && arr[i].charAt(0) != '-') { @@ -356,84 +362,93 @@ } } - switch(option.charAt(1)) + if(option === "-h") { - case 'h': + if(argument === null) { - if(argument === null) - { - throw new Ice.EndpointParseException( - "no argument provided for -h option in endpoint `tcp " + str + "'"); - } - - host = argument; - break; + throw new Ice.EndpointParseException( + "no argument provided for -h option in endpoint `tcp " + str + "'"); } - case 'p': + host = argument; + } + else if(option === "-p") + { + if(argument === null) { - if(argument === null) - { - throw new Ice.EndpointParseException( - "no argument provided for -p option in endpoint `tcp " + str + "'"); - } - - try - { - port = StringUtil.toInt(argument); - } - catch(ex) - { - throw new Ice.EndpointParseException("invalid port value `" + argument + - "' in endpoint `tcp " + str + "'"); - } - - if(port < 0 || port > 65535) - { - throw new Ice.EndpointParseException("port value `" + argument + - "' out of range in endpoint `tcp " + str + "'"); - } + throw new Ice.EndpointParseException( + "no argument provided for -p option in endpoint `tcp " + str + "'"); + } - break; + try + { + port = StringUtil.toInt(argument); + } + catch(ex) + { + throw new Ice.EndpointParseException("invalid port value `" + argument + + "' in endpoint `tcp " + str + "'"); } - case 't': + if(port < 0 || port > 65535) { - if(argument === null) - { - throw new Ice.EndpointParseException( - "no argument provided for -t option in endpoint `tcp " + str + "'"); - } + throw new Ice.EndpointParseException("port value `" + argument + + "' out of range in endpoint `tcp " + str + "'"); + } + } + else if(option === "-t") + { + if(argument === null) + { + throw new Ice.EndpointParseException( + "no argument provided for -t option in endpoint `tcp " + str + "'"); + } + if(argument == "infinite") + { + timeout = -1; + } + else + { + var invalid = false try { timeout = StringUtil.toInt(argument); } catch(ex) { + invalid = true + } + if(invalid || timeout < 1) + { throw new Ice.EndpointParseException( "invalid timeout value `" + argument + "' in endpoint `tcp " + str + "'"); } - - break; } - - case 'z': + } + else if(option === "-z") + { + if(argument !== null) { - if(argument !== null) - { - throw new Ice.EndpointParseException("unexpected argument `" + argument + - "' provided for -z option in `tcp " + str + "'"); - } - - compress = true; - break; + throw new Ice.EndpointParseException("unexpected argument `" + argument + + "' provided for -z option in `tcp " + str + "'"); } - default: + compress = true; + } + else if(option === "--sourceAddress") + { + if(argument === null) { - throw new Ice.EndpointParseException("unknown option `" + option + "' in `tcp " + str + "'"); + throw new Ice.EndpointParseException( + "no argument provided for --sourceAddress option in endpoint `tcp " + str + "'"); } + + sourceAddress = argument; + } + else + { + throw new Ice.EndpointParseException("unknown option `" + option + "' in `tcp " + str + "'"); } } @@ -458,7 +473,12 @@ host = ""; } - return new TcpEndpointI(instance, host, port, timeout, "", compress); + if(timeout == -2) + { + timeout = instance.defaultsAndOverrides().defaultTimeout + } + + return new TcpEndpointI(instance, host, port, sourceAddress, timeout, "", compress); }; TcpEndpointI.fromStream = function(s) @@ -469,16 +489,16 @@ var timeout = s.readInt(); var compress = s.readBool(); s.endReadEncaps(); - return new TcpEndpointI(s.instance, host, port, timeout, "", compress); + return new TcpEndpointI(s.instance, host, port, "", timeout, "", compress); }; - + Ice.TcpEndpointI = TcpEndpointI; global.Ice = Ice; var TCPEndpointInfoI = Class(Ice.TCPEndpointInfo, { - __init__: function(timeout, compress, host, port) + __init__: function(timeout, compress, host, port, sourceAddress) { - Ice.TCPEndpointInfo.call(this, timeout, compress, host, port); + Ice.TCPEndpointInfo.call(this, timeout, compress, host, port, sourceAddress); }, type: function() { diff --git a/js/src/Ice/TcpTransceiver.js b/js/src/Ice/TcpTransceiver.js index 57149b36d17..cbebe93d728 100644 --- a/js/src/Ice/TcpTransceiver.js +++ b/js/src/Ice/TcpTransceiver.js @@ -17,9 +17,9 @@ require("Ice/Connection"); require("Ice/Exception"); require("Ice/LocalException"); - + var Ice = global.Ice || {}; - + var Debug = Ice.Debug; var ExUtil = Ice.ExUtil; var Network = Ice.Network; @@ -184,7 +184,7 @@ while(packetSize > 0) { var slice = byteBuffer.b.slice(byteBuffer.position, byteBuffer.position + packetSize); - + var self = this; var sync = true; sync = this._fd.write(slice, null, function() { @@ -195,7 +195,7 @@ if(self._traceLevels.network >= 3) { - var msg = "sent " + packetSize + " of " + byteBuffer.remaining + " bytes via " + + var msg = "sent " + packetSize + " of " + byteBuffer.remaining + " bytes via " + self.type() + "\n" + self._desc; self._logger.trace(self._traceLevels.networkCat, msg); } @@ -216,13 +216,13 @@ { if(self._traceLevels.network >= 3) { - var msg = "sent " + packetSize + " of " + byteBuffer.remaining + " bytes via " + + var msg = "sent " + packetSize + " of " + byteBuffer.remaining + " bytes via " + self.type() + "\n" + self._desc; self._logger.trace(self._traceLevels.networkCat, msg); } - + byteBuffer.position = byteBuffer.position + packetSize; - + if(this._maxSendPacketSize > 0 && byteBuffer.remaining > this._maxSendPacketSize) { packetSize = this._maxSendPacketSize; @@ -370,7 +370,7 @@ } } }); - + function fdToString(fd, targetAddr) { if(fd === null) @@ -404,7 +404,7 @@ } return new Ice.SocketException(err.code, err); } - + function addressesToString(localHost, localPort, remoteHost, remotePort, targetAddr) { remoteHost = remoteHost === undefined ? null : remoteHost; @@ -432,7 +432,7 @@ return s.join(""); }; - + TcpTransceiver.createOutgoing = function(instance, addr) { var transceiver = new TcpTransceiver(instance); @@ -461,7 +461,7 @@ return transceiver; }; - + var ECONNABORTED = "ECONNABORTED"; var ECONNREFUSED = "ECONNREFUSED"; var ECONNRESET = "ECONNRESET" @@ -470,7 +470,7 @@ var ENOTCONN = "ENOTCONN"; var EPIPE = "EPIPE"; var ESHUTDOWN = "ESHUTDOWN" - var ETIMEDOUT = "ETIMEDOUT"; + var ETIMEDOUT = "ETIMEDOUT"; function connectionRefused(err) { diff --git a/js/src/Ice/browser/WSEndpoint.js b/js/src/Ice/browser/WSEndpoint.js index 31f1329b4c0..5f52a1c99ef 100644 --- a/js/src/Ice/browser/WSEndpoint.js +++ b/js/src/Ice/browser/WSEndpoint.js @@ -14,26 +14,27 @@ require("Ice/StringUtil"); require("Ice/Endpoint"); require("Ice/LocalException"); - + require("Ice/browser/WSTransceiver"); - + var Ice = global.Ice || {}; - + var Address = Ice.Address; var HashUtil = Ice.HashUtil; var StringUtil = Ice.StringUtil; var WSTransceiver = Ice.WSTransceiver; var Class = Ice.Class; - + var WSEndpoint = Class(Ice.Endpoint, { - __init__: function(instance, secure, ho, po, ti, conId, co, re) + __init__: function(instance, secure, ho, po, sif, ti, conId, co, re) { this._instance = instance; this._secure = secure; this._host = ho; this._port = po; this._timeout = ti; + this._sourceAddress = sif; this._connectionId = conId; this._compress = co; this._resource = re; @@ -61,14 +62,25 @@ s += " -p " + this._port; - if(this._timeout != -1) + if(this._sourceAddress.length > 0) + { + s += " --sourceAddress " + this._sourceAddress; + } + + if(this._timeout == -1) + { + s += " -t infinite"; + } + else { s += " -t " + this._timeout; } + if(this._compress) { s += " -z"; } + if(this._resource !== null && this._resource.length > 0) { s += " -r "; @@ -81,7 +93,8 @@ // getInfo: function() { - return new EndpointInfoI(this._secure, this._timeout, this._compress, this._host, this._port, this._resource); + return new EndpointInfoI(this._secure, this._timeout, this._compress, this._host, this._port, + this._sourceAddress, this._resource); }, // // Marshal the endpoint @@ -125,7 +138,8 @@ } else { - return new WSEndpoint(this._instance, this._secure, this._host, this._port, timeout, this._connectionId, this._compress, this._resource); + return new WSEndpoint(this._instance, this._secure, this._host, this._port, this._sourceAddress, + timeout, this._connectionId, this._compress, this._resource); } }, // @@ -139,7 +153,8 @@ } else { - return new WSEndpoint(this._instance, this._secure, this._host, this._port, this._timeout, connectionId, this._compress, this._resource); + return new WSEndpoint(this._instance, this._secure, this._host, this._port, this._sourceAddress, + this._timeout, connectionId, this._compress, this._resource); } }, // @@ -163,7 +178,8 @@ } else { - return new WSEndpoint(this._instance, this._secure, this._host, this._port, this._timeout, this._connectionId, compress, this._resource); + return new WSEndpoint(this._instance, this._secure, this._host, this._port, this._sourceAddress, + this._timeout, this._connectionId, compress, this._resource); } }, // @@ -207,12 +223,12 @@ if(this._instance.traceLevels().network >= 2) { this._instance.initializationData().logger.trace(this._instance.traceLevels().networkCat, - "trying to establish " + (this._secure ? "wss" : "ws") + " connection to " + this._host + ":" + + "trying to establish " + (this._secure ? "wss" : "ws") + " connection to " + this._host + ":" + this._port); } - return WSTransceiver.createOutgoing(this._instance, this._secure, new Address(this._host, this._port), - this._resource); + return WSTransceiver.createOutgoing(this._instance, this._secure, new Address(this._host, this._port), + this._resource); }, hashCode: function() { @@ -257,7 +273,7 @@ { return false; } - + if(this._resource !== p._resource) { return false; @@ -322,7 +338,7 @@ { return 1; } - + if(this._resource == p._resource) { return 0; @@ -345,15 +361,16 @@ this._hashCode = h; } }); - + WSEndpoint.fromString = function(instance, secure, str, oaEndpoint) { var host = null; var port = 0; - var timeout = -1; + var sourceAddress = ""; + var timeout = -2; var compress = false; var resource = ""; - + var protocol = secure ? "wss" : "ws"; var arr = str.split(/[ \t\n\r]+/); @@ -368,12 +385,6 @@ } var option = arr[i++]; - if(option.length != 2 && option.charAt(0) != '-') - { - throw new Ice.EndpointParseException("expected an endpoint option but found `" + option + - "' in endpoint `" + protocol + " " + str + "'"); - } - var argument = null; if(i < arr.length && arr[i].charAt(0) != '-') { @@ -384,99 +395,104 @@ } } - switch(option.charAt(1)) + + if(option === "-h") { - case 'h': + if(argument === null) { - if(argument === null) - { - throw new Ice.EndpointParseException("no argument provided for -h option in endpoint `" + - protocol + " " + str + "'"); - } - - host = argument; - break; + throw new Ice.EndpointParseException( + "no argument provided for -h option in endpoint `tcp " + str + "'"); } - case 'p': + host = argument; + } + else if(option === "-p") + { + if(argument === null) { - if(argument === null) - { - throw new Ice.EndpointParseException("no argument provided for -p option in endpoint `" + - protocol + " " + str + "'"); - } - - try - { - port = StringUtil.toInt(argument); - } - catch(ex) - { - throw new Ice.EndpointParseException("invalid port value `" + argument + - "' in endpoint `" + protocol + " " + str + "'"); - } - - if(port < 0 || port > 65535) - { - throw new Ice.EndpointParseException("port value `" + argument + - "' out of range in endpoint `" + protocol + " " + str + - "'"); - } + throw new Ice.EndpointParseException( + "no argument provided for -p option in endpoint `tcp " + str + "'"); + } - break; + try + { + port = StringUtil.toInt(argument); } - - case 'r': + catch(ex) { - if(argument === null) - { - throw new Ice.EndpointParseException("no argument provided for -r option in endpoint `" + - protocol + " " + str + "'"); - } + throw new Ice.EndpointParseException("invalid port value `" + argument + + "' in endpoint `tcp " + str + "'"); + } - resource = argument; - break; + if(port < 0 || port > 65535) + { + throw new Ice.EndpointParseException("port value `" + argument + + "' out of range in endpoint `tcp " + str + "'"); + } + } + else if(option === "-r") + { + if(argument === null) + { + throw new Ice.EndpointParseException("no argument provided for -r option in endpoint `" + + protocol + " " + str + "'"); } - case 't': + resource = argument; + } + else if(option === "-t") + { + if(argument === null) { - if(argument === null) - { - throw new Ice.EndpointParseException("no argument provided for -t option in endpoint `" + - protocol + " " + str + "'"); - } + throw new Ice.EndpointParseException( + "no argument provided for -t option in endpoint `tcp " + str + "'"); + } + if(argument == "infinite") + { + timeout = -1; + } + else + { + var invalid = false try { timeout = StringUtil.toInt(argument); } catch(ex) { - throw new Ice.EndpointParseException("invalid timeout value `" + argument + - "' in endpoint `" + protocol + " " + str + "'"); + invalid = true } - - break; - } - - case 'z': - { - if(argument !== null) + if(invalid || timeout < 1) { - throw new Ice.EndpointParseException("unexpected argument `" + argument + - "' provided for -z option in `" + protocol + " " + str + - "'"); + throw new Ice.EndpointParseException( + "invalid timeout value `" + argument + "' in endpoint `tcp " + str + "'"); } - - compress = true; - break; + } + } + else if(option === "-z") + { + if(argument !== null) + { + throw new Ice.EndpointParseException("unexpected argument `" + argument + + "' provided for -z option in `tcp " + str + "'"); } - default: + compress = true; + } + else if(option === "--sourceAddress") + { + if(argument === null) { - throw new Ice.EndpointParseException("unknown option `" + option + "' in `" + protocol + " " + - str + "'"); + throw new Ice.EndpointParseException( + "no argument provided for --sourceAddress option in endpoint `tcp " + str + "'"); } + + sourceAddress = argument; + } + else + { + throw new Ice.EndpointParseException("unknown option `" + option + "' in `tcp " + str + "'"); } } @@ -501,7 +517,13 @@ { host = ""; } - return new WSEndpoint(instance, secure, host, port, timeout, "", compress, resource); + + if(timeout == -2) + { + timeout = instance.defaultsAndOverrides().defaultTimeout + } + + return new WSEndpoint(instance, secure, host, port, sourceAddress, timeout, "", compress, resource); }; WSEndpoint.fromStream = function(s, secure) @@ -513,16 +535,16 @@ var compress = s.readBool(); var resource = s.readString(); s.endReadEncaps(); - return new WSEndpoint(s.instance, secure, host, port, timeout, "", compress, resource); + return new WSEndpoint(s.instance, secure, host, port, "", timeout, "", compress, resource); }; - + Ice.WSEndpoint = WSEndpoint; global.Ice = Ice; - + var EndpointInfoI = Class(Ice.WSEndpointInfo, { - __init__: function(secure, timeout, compress, host, port, resource) + __init__: function(secure, timeout, compress, host, port, sourceAddress, resource) { - Ice.WSEndpointInfo.call(this, timeout, compress, host, port, resource); + Ice.WSEndpointInfo.call(this, timeout, compress, host, port, sourceAddress, resource); this.secure = secure; }, type: function() diff --git a/js/test/Ice/proxy/Client.js b/js/test/Ice/proxy/Client.js index bb8f8771a95..f2f9af96e2d 100644 --- a/js/test/Ice/proxy/Client.js +++ b/js/test/Ice/proxy/Client.js @@ -329,7 +329,7 @@ var id = new Ice.Identity("test", ",X2QNUAzSBcJ_e$AV;E\\"); var id2 = communicator.stringToIdentity(communicator.identityToString(id)); test(id.equals(id2)); - + id = new Ice.Identity("test", ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\"); id2 = communicator.stringToIdentity(communicator.identityToString(id)); test(id.equals(id2)); @@ -504,6 +504,89 @@ test(base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion().equals(Ice.Encoding_1_0)); test(base.ice_encodingVersion(Ice.Encoding_1_1).ice_getEncodingVersion().equals(Ice.Encoding_1_1)); test(!base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion().equals(Ice.Encoding_1_1)); + + try + { + base.ice_timeout(0); + test(false); + } + catch(ex) + { + } + + try + { + base.ice_timeout(-1); + } + catch(ex) + { + test(false); + } + + try + { + base.ice_timeout(-2); + test(false); + } + catch(ex) + { + } + + try + { + base.ice_invocationTimeout(0); + test(false); + } + catch(ex) + { + } + + try + { + base.ice_invocationTimeout(-1); + } + catch(ex) + { + test(false); + } + + try + { + base.ice_invocationTimeout(-2); + test(false); + } + catch(ex) + { + } + + try + { + base.ice_locatorCacheTimeout(0); + } + catch(ex) + { + test(false); + } + + try + { + base.ice_locatorCacheTimeout(-1); + } + catch(ex) + { + test(false); + } + + try + { + base.ice_locatorCacheTimeout(-2); + test(false); + } + catch(ex) + { + } + + out.writeLine("ok"); out.write("testing proxy comparison... "); diff --git a/py/modules/IcePy/Proxy.cpp b/py/modules/IcePy/Proxy.cpp index e0f61858496..90cf02923b7 100644 --- a/py/modules/IcePy/Proxy.cpp +++ b/py/modules/IcePy/Proxy.cpp @@ -827,6 +827,11 @@ proxyIceLocatorCacheTimeout(ProxyObject* self, PyObject* args) { newProxy = (*self->proxy)->ice_locatorCacheTimeout(timeout); } + catch(const IceUtil::IllegalArgumentException& ex) + { + PyErr_Format(PyExc_RuntimeError, "%s", STRCAST(ex.reason().c_str())); + return 0; + } catch(const Ice::Exception& ex) { setPythonException(ex); @@ -855,6 +860,11 @@ proxyIceInvocationTimeout(ProxyObject* self, PyObject* args) { newProxy = (*self->proxy)->ice_invocationTimeout(timeout); } + catch(const IceUtil::IllegalArgumentException& ex) + { + PyErr_Format(PyExc_RuntimeError, "%s", STRCAST(ex.reason().c_str())); + return 0; + } catch(const Ice::Exception& ex) { setPythonException(ex); @@ -1586,6 +1596,11 @@ proxyIceTimeout(ProxyObject* self, PyObject* args) { newProxy = (*self->proxy)->ice_timeout(timeout); } + catch(const IceUtil::IllegalArgumentException& ex) + { + PyErr_Format(PyExc_RuntimeError, "%s", STRCAST(ex.reason().c_str())); + return 0; + } catch(const Ice::Exception& ex) { setPythonException(ex); diff --git a/py/test/Ice/proxy/AllTests.py b/py/test/Ice/proxy/AllTests.py index 0d0f7468a5a..97c5a74dfbb 100644 --- a/py/test/Ice/proxy/AllTests.py +++ b/py/test/Ice/proxy/AllTests.py @@ -376,6 +376,57 @@ def allTests(communicator, collocated): 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) + except RuntimeError: + pass + + try: + base.ice_timeout(-1) + except RuntimeError: + test(False) + + try: + base.ice_timeout(-2) + test(False) + except RuntimeError: + pass + + try: + base.ice_invocationTimeout(0) + test(False) + except RuntimeError: + pass + + try: + base.ice_invocationTimeout(-1) + except RuntimeError: + test(False) + + try: + base.ice_invocationTimeout(-2) + test(False) + except RuntimeError: + pass + + try: + base.ice_locatorCacheTimeout(0) + except RuntimeError: + test(False) + + try: + base.ice_locatorCacheTimeout(-1) + except RuntimeError: + test(False) + + try: + base.ice_locatorCacheTimeout(-2) + test(False) + except RuntimeError: + pass + print("ok") sys.stdout.write("testing proxy comparison... ") diff --git a/rb/src/IceRuby/Proxy.cpp b/rb/src/IceRuby/Proxy.cpp index e239414f1f8..686b4b10f42 100644 --- a/rb/src/IceRuby/Proxy.cpp +++ b/rb/src/IceRuby/Proxy.cpp @@ -446,9 +446,16 @@ IceRuby_ObjectPrx_ice_locatorCacheTimeout(VALUE self, VALUE timeout) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - long t = getInteger(timeout); - return createProxy(p->ice_locatorCacheTimeout(static_cast<Ice::Int>(t)), rb_class_of(self)); + try + { + Ice::ObjectPrx p = getProxy(self); + long t = getInteger(timeout); + return createProxy(p->ice_locatorCacheTimeout(static_cast<Ice::Int>(t)), rb_class_of(self)); + } + catch(const IceUtil::IllegalArgumentException& ex) + { + throw RubyException(rb_eArgError, ex.reason().c_str()); + } } ICE_RUBY_CATCH return Qnil; @@ -460,9 +467,16 @@ IceRuby_ObjectPrx_ice_invocationTimeout(VALUE self, VALUE timeout) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - long t = getInteger(timeout); - return createProxy(p->ice_invocationTimeout(static_cast<Ice::Int>(t)), rb_class_of(self)); + try + { + Ice::ObjectPrx p = getProxy(self); + long t = getInteger(timeout); + return createProxy(p->ice_invocationTimeout(static_cast<Ice::Int>(t)), rb_class_of(self)); + } + catch(const IceUtil::IllegalArgumentException& ex) + { + throw RubyException(rb_eArgError, ex.reason().c_str()); + } } ICE_RUBY_CATCH return Qnil; @@ -852,9 +866,16 @@ IceRuby_ObjectPrx_ice_timeout(VALUE self, VALUE t) { ICE_RUBY_TRY { - Ice::ObjectPrx p = getProxy(self); - Ice::Int timeout = static_cast<Ice::Int>(getInteger(t)); - return createProxy(p->ice_timeout(timeout), rb_class_of(self)); + try + { + Ice::ObjectPrx p = getProxy(self); + Ice::Int timeout = static_cast<Ice::Int>(getInteger(t)); + return createProxy(p->ice_timeout(timeout), rb_class_of(self)); + } + catch(const IceUtil::IllegalArgumentException& ex) + { + throw RubyException(rb_eArgError, ex.reason().c_str()); + } } ICE_RUBY_CATCH return Qnil; diff --git a/rb/test/Ice/proxy/AllTests.rb b/rb/test/Ice/proxy/AllTests.rb index 3b9b0f07b50..0e1c21e0efe 100644 --- a/rb/test/Ice/proxy/AllTests.rb +++ b/rb/test/Ice/proxy/AllTests.rb @@ -369,6 +369,61 @@ def allTests(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) + + begin + base.ice_timeout(0) + test(false) + rescue + end + + begin + base.ice_timeout(-1) + rescue + test(false) + end + + begin + base.ice_timeout(-2) + test(false) + rescue + end + + begin + base.ice_invocationTimeout(0) + test(false) + rescue + end + + begin + base.ice_invocationTimeout(-1) + rescue + test(false) + end + + begin + base.ice_invocationTimeout(-2) + test(false) + rescue + end + + begin + base.ice_locatorCacheTimeout(0) + rescue + test(false) + end + + begin + base.ice_locatorCacheTimeout(-1) + rescue + test(false) + end + + begin + base.ice_locatorCacheTimeout(-2) + test(false) + rescue + end + puts "ok" print "testing proxy comparison... " |