summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Freeze/BackgroundSaveEvictorI.cpp1
-rw-r--r--cpp/src/Freeze/EvictorI.cpp2
-rw-r--r--cpp/src/Freeze/EvictorI.h9
-rw-r--r--cpp/src/Freeze/TransactionalEvictorI.cpp1
-rw-r--r--cpp/src/Ice/Exception.cpp8
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp34
-rw-r--r--cpp/src/Ice/ObjectAdapterI.h1
-rw-r--r--cpp/test/Ice/exceptions/AllTests.cpp18
8 files changed, 59 insertions, 15 deletions
diff --git a/cpp/src/Freeze/BackgroundSaveEvictorI.cpp b/cpp/src/Freeze/BackgroundSaveEvictorI.cpp
index 52c3a64969f..1da527561e3 100644
--- a/cpp/src/Freeze/BackgroundSaveEvictorI.cpp
+++ b/cpp/src/Freeze/BackgroundSaveEvictorI.cpp
@@ -233,6 +233,7 @@ Ice::ObjectPrx
Freeze::BackgroundSaveEvictorI::addFacet(const ObjectPtr& servant, const Identity& ident, const string& facet)
{
checkIdentity(ident);
+ checkServant(servant);
DeactivateController::Guard deactivateGuard(_deactivateController);
ObjectStore<BackgroundSaveEvictorElement>* store = findStore(facet, _createDb);
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp
index 626fbd47231..c9c4be90440 100644
--- a/cpp/src/Freeze/EvictorI.cpp
+++ b/cpp/src/Freeze/EvictorI.cpp
@@ -275,8 +275,6 @@ Freeze::EvictorIBase::locate(const Current& current, LocalObjectPtr& cookie)
}
-
-
void
Freeze::EvictorIBase::initialize(const Identity& ident, const string& facet, const ObjectPtr& servant)
{
diff --git a/cpp/src/Freeze/EvictorI.h b/cpp/src/Freeze/EvictorI.h
index 8995b76da29..ec2792fe541 100644
--- a/cpp/src/Freeze/EvictorI.h
+++ b/cpp/src/Freeze/EvictorI.h
@@ -342,6 +342,15 @@ checkIdentity(const Ice::Identity& ident)
}
}
+inline void
+checkServant(const Ice::ObjectPtr& servant)
+{
+ if(servant == 0)
+ {
+ throw Ice::IllegalServantException(__FILE__, __LINE__, "cannot add null servant to Freeze Evictor");
+ }
+}
+
}
#endif
diff --git a/cpp/src/Freeze/TransactionalEvictorI.cpp b/cpp/src/Freeze/TransactionalEvictorI.cpp
index c41531f34ae..46680e0ee0f 100644
--- a/cpp/src/Freeze/TransactionalEvictorI.cpp
+++ b/cpp/src/Freeze/TransactionalEvictorI.cpp
@@ -137,6 +137,7 @@ ObjectPrx
Freeze::TransactionalEvictorI::addFacet(const ObjectPtr& servant, const Identity& ident, const string& facet)
{
checkIdentity(ident);
+ checkServant(servant);
DeactivateController::Guard deactivateGuard(_deactivateController);
ObjectStore<TransactionalEvictorElement>* store = findStore(facet, _createDb);
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp
index 0fd53c3cae2..af4e44e6087 100644
--- a/cpp/src/Ice/Exception.cpp
+++ b/cpp/src/Ice/Exception.cpp
@@ -323,6 +323,14 @@ Ice::IllegalIdentityException::ice_print(ostream& out) const
out << "'";
}
+void
+Ice::IllegalServantException::ice_print(ostream& out) const
+{
+ Exception::ice_print(out);
+ out << ":\nillegal servant: `" << reason << "'";
+}
+
+
static void
printFailedRequestData(ostream& out, const RequestFailedException& ex)
{
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index dbf3d5183e4..33b275bd616 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -44,6 +44,25 @@ using namespace std;
using namespace Ice;
using namespace IceInternal;
+namespace
+{
+inline void checkIdentity(const Identity& ident)
+{
+ if(ident.name.size() == 0)
+ {
+ throw IllegalIdentityException(__FILE__, __LINE__, ident);
+ }
+}
+
+inline void checkServant(const ObjectPtr& servant)
+{
+ if(servant == 0)
+ {
+ throw IllegalServantException(__FILE__, __LINE__, "cannot add null servant to Object Adapter");
+ }
+}
+}
+
string
Ice::ObjectAdapterI::getName() const
{
@@ -428,6 +447,7 @@ Ice::ObjectAdapterI::addFacet(const ObjectPtr& object, const Identity& ident, co
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
checkForDeactivation();
+ checkServant(object);
checkIdentity(ident);
_servantManager->addServant(object, ident, facet);
@@ -452,10 +472,11 @@ Ice::ObjectAdapterI::addFacetWithUUID(const ObjectPtr& object, const string& fac
void
Ice::ObjectAdapterI::addDefaultServant(const ObjectPtr& servant, const string& category)
{
+ checkServant(servant);
+
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
checkForDeactivation();
-
_servantManager->addDefaultServant(servant, category);
}
@@ -1140,17 +1161,6 @@ Ice::ObjectAdapterI::checkForDeactivation() const
}
}
-void
-Ice::ObjectAdapterI::checkIdentity(const Identity& ident)
-{
- if(ident.name.size() == 0)
- {
- IllegalIdentityException e(__FILE__, __LINE__);
- e.id = ident;
- throw e;
- }
-}
-
vector<EndpointIPtr>
Ice::ObjectAdapterI::parseEndpoints(const string& endpts, bool oaEndpoints) const
{
diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h
index 55946b580ef..52a3865c714 100644
--- a/cpp/src/Ice/ObjectAdapterI.h
+++ b/cpp/src/Ice/ObjectAdapterI.h
@@ -111,7 +111,6 @@ private:
ObjectPrx newDirectProxy(const Identity&, const std::string&) const;
ObjectPrx newIndirectProxy(const Identity&, const std::string&, const std::string&) const;
void checkForDeactivation() const;
- static void checkIdentity(const Identity&);
std::vector<IceInternal::EndpointIPtr> parseEndpoints(const std::string&, bool) const;
std::vector<IceInternal::EndpointIPtr> parsePublishedEndpoints();
void updateLocatorRegistry(const IceInternal::LocatorInfoPtr&, const Ice::ObjectPrx&, bool);
diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp
index 605d1f5f9a7..81a093f5c2c 100644
--- a/cpp/test/Ice/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/exceptions/AllTests.cpp
@@ -1024,6 +1024,24 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
}
+ try
+ {
+ adapter->add(obj, communicator->stringToIdentity(""));
+ }
+ catch(const Ice::IllegalIdentityException& ex)
+ {
+ test(ex.id.name == "");
+ }
+
+ try
+ {
+ adapter->add(0, communicator->stringToIdentity("x"));
+ }
+ catch(const Ice::IllegalServantException&)
+ {
+ }
+
+
adapter->remove(communicator->stringToIdentity("x"));
try
{