diff options
author | Benoit Foucher <benoit@zeroc.com> | 2002-11-25 22:23:00 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2002-11-25 22:23:00 +0000 |
commit | e0ac69f7b067964774a5d3d241bc5496564e37ba (patch) | |
tree | 0db95ebe5daf6d694b80060c79c0cfd6436bfffb /cpp | |
parent | more detail for CompressionException (diff) | |
download | ice-e0ac69f7b067964774a5d3d241bc5496564e37ba.tar.bz2 ice-e0ac69f7b067964774a5d3d241bc5496564e37ba.tar.xz ice-e0ac69f7b067964774a5d3d241bc5496564e37ba.zip |
- Added Ice.NullHandleAbort property
- Fixed Locator.ice exception names to be consistent with other exceptions.
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/doc/Properties.sgml | 17 | ||||
-rw-r--r-- | cpp/slice/Ice/Locator.ice | 50 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 12 | ||||
-rw-r--r-- | cpp/src/Ice/LocatorInfo.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IcePack/LocatorI.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IcePack/LocatorRegistryI.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceUtil/Exception.cpp | 11 | ||||
-rw-r--r-- | cpp/test/Ice/location/ServerLocator.cpp | 4 |
9 files changed, 85 insertions, 27 deletions
diff --git a/cpp/doc/Properties.sgml b/cpp/doc/Properties.sgml index a346ba37531..6b8fb97aa5c 100644 --- a/cpp/doc/Properties.sgml +++ b/cpp/doc/Properties.sgml @@ -603,6 +603,23 @@ value of <literal>Ice.ProgramName</literal>. (Unix only.) </section> </section> +<section><title>Ice.NullHandleAbort</title> +<section><title>Synopsis</title> +<synopsis> +Ice.NullHandleAbort=<replaceable>num</replaceable> +</synopsis> +</section> +<section> +<title>Description</title> +<para> +If <replaceable>num</replaceable> is set to a value larger than zero, +IceUtil smart pointers will cause the program to abort instead of +raising an <literal>IceUtil::NullHandleException</literal> exception +if a null smart pointer is accessed. (C++ only.) +</para> +</section> +</section> + </section> <!-- ********************************************************************** --> diff --git a/cpp/slice/Ice/Locator.ice b/cpp/slice/Ice/Locator.ice index aa8ad0836a9..1a2c2595aa4 100644 --- a/cpp/slice/Ice/Locator.ice +++ b/cpp/slice/Ice/Locator.ice @@ -18,6 +18,26 @@ module Ice { +/** + * + * This exception is raised if the server tries to set endpoints for + * an adapter which is not registered with the locator. + * + **/ +exception AdapterNotRegisteredException +{ +}; + +/** + * + * This exception is raised if the server tries to set endpoints for + * an adapter which is already active. + * + **/ +exception AdapterAlreadyActiveException +{ +}; + interface LocatorRegistry; /** @@ -40,10 +60,14 @@ interface Locator * * @param id The adapter id. * - * @return The adapter proxy or null if the adapter is not found. + * @return The adapter proxy or null if the adapter is not active. + * + * @throws AdapterNotRegisteredException Raised if the adapter + * can't be found. * **/ - nonmutating Object* findAdapterById(string id); + nonmutating Object* findAdapterById(string id) + throws AdapterNotRegisteredException; /** * @@ -57,26 +81,6 @@ interface Locator /** * - * This exception is raised if the server tries to set endpoints for - * an adapter which is not registered with the locator. - * - **/ -exception AdapterNotRegistered -{ -}; - -/** - * - * This exception is raised if the server tries to set endpoints for - * an adapter which is already active. - * - **/ -exception AdapterAlreadyActive -{ -}; - -/** - * * The &Ice; locator registry interface. This interface is used by * servers to register adapter endpoints with the locator. * @@ -107,7 +111,7 @@ interface LocatorRegistry * */ idempotent void setAdapterDirectProxy(string id, Object* proxy) - throws AdapterNotRegistered, AdapterAlreadyActive; + throws AdapterNotRegisteredException, AdapterAlreadyActiveException; }; }; diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 7f95182d365..614803f09a7 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -57,6 +57,13 @@ IceUtil::Mutex* Instance::_globalStateMutex = new IceUtil::Mutex; string Instance::_identForOpenlog; #endif +namespace IceUtil +{ + +extern bool nullHandleAbort; + +}; + namespace IceInternal { @@ -299,6 +306,11 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, int& argc, } openlog(_identForOpenlog.c_str(), LOG_PID, LOG_USER); } + + if(_properties->getPropertyAsInt("Ice.NullHandleAbort") > 0) + { + IceUtil::nullHandleAbort = true; + } #endif } diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp index 174fb756d3a..958678f93ca 100644 --- a/cpp/src/Ice/LocatorInfo.cpp +++ b/cpp/src/Ice/LocatorInfo.cpp @@ -249,6 +249,14 @@ IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, bool& cached) endpoints = object->__reference()->endpoints; } } + catch(const AdapterNotRegisteredException&) + { + if(ref->instance->traceLevels()->location >= 1) + { + Trace out(ref->instance->logger(), ref->instance->traceLevels()->locationCat); + out << "adapter `" << ref->adapterId << "' is not registered"; + } + } catch(const LocalException& ex) { // diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index cdc3f5d4535..5504ded919e 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -84,13 +84,13 @@ Ice::ObjectAdapterI::activate() { _locatorInfo->getLocatorRegistry()->setAdapterDirectProxy(_id, newDirectProxy(ident)); } - catch(const Ice::AdapterNotRegistered&) + catch(const Ice::AdapterNotRegisteredException&) { ObjectAdapterNotRegisteredException ex(__FILE__, __LINE__); ex.name = _name; throw ex; } - catch(const Ice::AdapterAlreadyActive&) + catch(const Ice::AdapterAlreadyActiveException&) { ObjectAdapterIdInUseException ex(__FILE__, __LINE__); ex.id = _id; diff --git a/cpp/src/IcePack/LocatorI.cpp b/cpp/src/IcePack/LocatorI.cpp index ab2822d7fbf..57af5cf4a48 100644 --- a/cpp/src/IcePack/LocatorI.cpp +++ b/cpp/src/IcePack/LocatorI.cpp @@ -44,12 +44,14 @@ IcePack::LocatorI::findAdapterById(const string& id, const Ice::Current&) const } catch(const AdapterNotExistException&) { + throw Ice::AdapterNotRegisteredException(); } catch(const Ice::ObjectNotExistException&) { // // Expected if the adapter is destroyed. // + throw Ice::AdapterNotRegisteredException(); } catch(const Ice::NoEndpointException&) { diff --git a/cpp/src/IcePack/LocatorRegistryI.cpp b/cpp/src/IcePack/LocatorRegistryI.cpp index c6e05275832..78e56f94e2c 100644 --- a/cpp/src/IcePack/LocatorRegistryI.cpp +++ b/cpp/src/IcePack/LocatorRegistryI.cpp @@ -43,7 +43,7 @@ IcePack::LocatorRegistryI::setAdapterDirectProxy(const string& id, const Ice::Ob } catch(const AdapterActiveException&) { - throw Ice::AdapterAlreadyActive(); + throw Ice::AdapterAlreadyActiveException(); } catch(const Ice::ObjectNotExistException&) { @@ -96,7 +96,7 @@ IcePack::LocatorRegistryI::setAdapterDirectProxy(const string& id, const Ice::Ob } else { - throw Ice::AdapterNotRegistered(); + throw Ice::AdapterNotRegisteredException(); } } } diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index 9a91d33ae3a..cf52e06e6a8 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -16,6 +16,13 @@ using namespace std; +namespace IceUtil +{ + +bool nullHandleAbort = false; + +}; + IceUtil::Exception::Exception() : _file(0), _line(0) @@ -82,6 +89,10 @@ IceUtil::operator<<(ostream& out, const IceUtil::Exception& ex) IceUtil::NullHandleException::NullHandleException(const char* file, int line) : Exception(file, line) { + if(nullHandleAbort) + { + assert(false); + } } string diff --git a/cpp/test/Ice/location/ServerLocator.cpp b/cpp/test/Ice/location/ServerLocator.cpp index d3597ebac60..c79dd06d498 100644 --- a/cpp/test/Ice/location/ServerLocator.cpp +++ b/cpp/test/Ice/location/ServerLocator.cpp @@ -30,6 +30,10 @@ ServerLocatorRegistry::setAdapterDirectProxy(const ::std::string& adapter, const Ice::ObjectPrx ServerLocatorRegistry::getAdapter(const ::std::string& adapter) { + if(_adapters.find(adapter) == _adapters.end()) + { + throw Ice::AdapterNotRegisteredException(); + } return _adapters[adapter]; } |