summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBrent Eagles <brent@zeroc.com>2005-09-07 16:14:20 +0000
committerBrent Eagles <brent@zeroc.com>2005-09-07 16:14:20 +0000
commit4e631700d66c51a96210e2bcbd8b3f63d8b0b9f4 (patch)
tree5b0d75ebdea90cbdfb6c3955b601ece88ccbceee /cpp
parentBug 371: closeSocket can hide real errors (diff)
downloadice-4e631700d66c51a96210e2bcbd8b3f63d8b0b9f4.tar.bz2
ice-4e631700d66c51a96210e2bcbd8b3f63d8b0b9f4.tar.xz
ice-4e631700d66c51a96210e2bcbd8b3f63d8b0b9f4.zip
revising fixes for bug 431
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp15
-rw-r--r--cpp/src/Ice/ObjectAdapterFactory.cpp4
-rw-r--r--cpp/src/Ice/ObjectAdapterFactory.h2
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp7
-rw-r--r--cpp/src/Ice/ObjectAdapterI.h2
-rw-r--r--cpp/test/Ice/exceptions/AllTests.cpp16
6 files changed, 25 insertions, 21 deletions
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index 01fa8eac7a7..3fb9e387e67 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -134,24 +134,13 @@ Ice::CommunicatorI::proxyToString(const ObjectPrx& proxy) const
ObjectAdapterPtr
Ice::CommunicatorI::createObjectAdapter(const string& name)
{
- return _instance->objectAdapterFactory()->createObjectAdapter(name);
+ return createObjectAdapterWithEndpoints(name, getProperties()->getProperty(name + ".Endpoints"));
}
ObjectAdapterPtr
Ice::CommunicatorI::createObjectAdapterWithEndpoints(const string& name, const string& endpoints)
{
- const string propertyKey = name + ".Endpoints";
- const string originalValue = getProperties()->getProperty(propertyKey);
- try
- {
- getProperties()->setProperty(propertyKey, endpoints);
- return createObjectAdapter(name);
- }
- catch(const AlreadyRegisteredException&)
- {
- getProperties()->setProperty(propertyKey, originalValue);
- throw;
- }
+ return _instance->objectAdapterFactory()->createObjectAdapter(name, endpoints);
}
void
diff --git a/cpp/src/Ice/ObjectAdapterFactory.cpp b/cpp/src/Ice/ObjectAdapterFactory.cpp
index 9bcd0e6580b..e61834a856f 100644
--- a/cpp/src/Ice/ObjectAdapterFactory.cpp
+++ b/cpp/src/Ice/ObjectAdapterFactory.cpp
@@ -100,7 +100,7 @@ IceInternal::ObjectAdapterFactory::waitForShutdown()
}
ObjectAdapterPtr
-IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name)
+IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const string& endpoints)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
@@ -115,7 +115,7 @@ IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name)
throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter", name);
}
- ObjectAdapterIPtr adapter = new ObjectAdapterI(_instance, _communicator, name);
+ ObjectAdapterIPtr adapter = new ObjectAdapterI(_instance, _communicator, name, endpoints);
_adapters.insert(make_pair(name, adapter));
return adapter;
}
diff --git a/cpp/src/Ice/ObjectAdapterFactory.h b/cpp/src/Ice/ObjectAdapterFactory.h
index f74c2a5d38a..18c419cab6f 100644
--- a/cpp/src/Ice/ObjectAdapterFactory.h
+++ b/cpp/src/Ice/ObjectAdapterFactory.h
@@ -24,7 +24,7 @@ public:
void shutdown();
void waitForShutdown();
- ::Ice::ObjectAdapterPtr createObjectAdapter(const std::string&);
+ ::Ice::ObjectAdapterPtr createObjectAdapter(const std::string&, const std::string&);
::Ice::ObjectAdapterPtr findObjectAdapter(const ::Ice::ObjectPrx&);
void flushBatchRequests() const;
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index d5a041cbefb..c00e7d28f91 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -680,7 +680,7 @@ Ice::ObjectAdapterI::getServantManager() const
}
Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const CommunicatorPtr& communicator,
- const string& name) :
+ const string& name, const string& endpointInfo) :
_deactivated(false),
_instance(instance),
_communicator(communicator),
@@ -699,8 +699,7 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
// The connection factory might change it, for example, to
// fill in the real port number.
//
- string endpts = _instance->properties()->getProperty(name + ".Endpoints");
- vector<EndpointPtr> endpoints = parseEndpoints(endpts);
+ vector<EndpointPtr> endpoints = parseEndpoints(endpointInfo);
for(vector<EndpointPtr>::iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
_incomingConnectionFactories.push_back(new IncomingConnectionFactory(instance, *p, this));
@@ -710,7 +709,7 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
// Parse published endpoints. These are used in proxies
// instead of the connection factory endpoints.
//
- endpts = _instance->properties()->getProperty(name + ".PublishedEndpoints");
+ string endpts = _instance->properties()->getProperty(name + ".PublishedEndpoints");
_publishedEndpoints = parseEndpoints(endpts);
string router = _instance->properties()->getProperty(_name + ".Router");
diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h
index c6ca6b87de7..984ea7888af 100644
--- a/cpp/src/Ice/ObjectAdapterI.h
+++ b/cpp/src/Ice/ObjectAdapterI.h
@@ -84,7 +84,7 @@ public:
private:
- ObjectAdapterI(const IceInternal::InstancePtr&, const CommunicatorPtr&, const std::string&);
+ ObjectAdapterI(const IceInternal::InstancePtr&, const CommunicatorPtr&, const std::string&, const std::string&);
virtual ~ObjectAdapterI();
friend class IceInternal::ObjectAdapterFactory;
diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp
index 2b8eacbdca4..c4ed6ef4887 100644
--- a/cpp/test/Ice/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/exceptions/AllTests.cpp
@@ -573,6 +573,22 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated)
{
// Expected
}
+
+ communicator->getProperties()->setProperty("TestAdapter0.Endpoints", "");
+ try
+ {
+ Ice::ObjectAdapterPtr second =
+ communicator->createObjectAdapterWithEndpoints("TestAdapter0", "ssl -h foo -p 12346 -t 10000");
+ test(false);
+ }
+ catch(const Ice::AlreadyRegisteredException&)
+ {
+ // Expected.
+ }
+ //
+ // Properties must remain unaffected if an exception occurs.
+ //
+ test(communicator->getProperties()->getProperty("TestAdapter0.Endpoints") == "");
first->deactivate();
}
cout << "ok" << endl;