summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES11
-rw-r--r--config/PropertyNames.xml1
-rw-r--r--cpp/src/Ice/ConnectionFactory.cpp10
-rw-r--r--cpp/src/Ice/ConnectionFactory.h5
-rw-r--r--cpp/src/Ice/ConnectionI.cpp20
-rw-r--r--cpp/src/Ice/ConnectionI.h5
-rw-r--r--cpp/src/Ice/Instance.cpp6
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp17
-rw-r--r--cpp/src/Ice/ObjectAdapterI.h2
-rw-r--r--cpp/src/IceGrid/RegistryI.cpp4
-rw-r--r--cpp/src/IceStorm/Service.cpp4
-rw-r--r--cpp/test/Ice/exceptions/AllTests.cpp22
-rw-r--r--cpp/test/Ice/exceptions/Server.cpp10
-rw-r--r--cpp/test/Ice/exceptions/ServerAMD.cpp10
-rw-r--r--cs/src/Ice/BasicStream.cs6
-rw-r--r--cs/src/Ice/ConnectionFactory.cs12
-rw-r--r--cs/src/Ice/ConnectionI.cs21
-rw-r--r--cs/src/Ice/Instance.cs6
-rw-r--r--cs/src/Ice/ObjectAdapterI.cs24
-rw-r--r--cs/test/Ice/exceptions/AllTests.cs21
-rw-r--r--cs/test/Ice/exceptions/Server.cs15
-rw-r--r--java/src/Ice/src/main/java/Ice/ConnectionI.java22
-rw-r--r--java/src/Ice/src/main/java/Ice/ObjectAdapterI.java23
-rw-r--r--java/src/Ice/src/main/java/IceInternal/BasicStream.java7
-rw-r--r--java/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java14
-rw-r--r--java/src/Ice/src/main/java/IceInternal/Instance.java6
-rw-r--r--java/test/src/main/java/test/Ice/exceptions/AMDServer.java12
-rw-r--r--java/test/src/main/java/test/Ice/exceptions/AllTests.java21
-rw-r--r--java/test/src/main/java/test/Ice/exceptions/Server.java10
-rw-r--r--js/src/Ice/ConnectionI.js5
-rw-r--r--js/src/Ice/Instance.js6
-rw-r--r--js/src/Ice/ObjectAdapterI.js19
-rw-r--r--js/test/Ice/exceptions/Client.js1
-rw-r--r--php/test/Ice/exceptions/Client.php4
-rwxr-xr-xphp/test/Ice/exceptions/run.py12
-rw-r--r--py/test/Ice/exceptions/AllTests.py16
-rwxr-xr-xpy/test/Ice/exceptions/Client.py1
-rwxr-xr-xpy/test/Ice/exceptions/Server.py11
-rwxr-xr-xpy/test/Ice/exceptions/ServerAMD.py11
-rw-r--r--rb/test/Ice/exceptions/AllTests.rb4
-rwxr-xr-xrb/test/Ice/exceptions/Client.rb1
-rw-r--r--slice/Ice/LocalException.ice9
42 files changed, 331 insertions, 116 deletions
diff --git a/CHANGES b/CHANGES
index cb6e6658357..843051bb751 100644
--- a/CHANGES
+++ b/CHANGES
@@ -39,11 +39,18 @@ General Changes
- We have relaxed the semantics of Ice.MessageSizeMax. The check for
the maximum message size is now only performed on the receiver
side. If the size of the message is superior to the limit the
- Ice::MemoryLimitException is raised and the connection is closed.
-
+ Ice::MemoryLimitException is raised and the connection is closed.
+
Previously, it was also used to limit the amount of data sent to a
peer (either for a request or reply). This is no longer the case.
+ A null or negative value now also disables the check and allows an
+ unlimited amout of data to be received. This should only be used in
+ a trusted environment.
+
+ Finally, support for the <object adapter>.MessageSizeMax property
+ was added to allow setting this limit on a per object adapter basis.
+
- The Ice run time now raises Ice::IllegalServantException if a null
servant is provided to a method that requires a non-null servant
(such as the Ice::ObjectAdapter::add methods or the Freeze evictor
diff --git a/config/PropertyNames.xml b/config/PropertyNames.xml
index 5a63b11b31a..345e08b1b44 100644
--- a/config/PropertyNames.xml
+++ b/config/PropertyNames.xml
@@ -280,6 +280,7 @@ generated from the section label.
<suffix name="Router" class="proxy"/>
<suffix name="ProxyOptions" />
<suffix name="ThreadPool" class="threadpool" />
+ <suffix name="MessageSizeMax" />
</class>
<class name="deprecatedthreadpool" prefix-only="true">
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp
index 154e1ef193b..db378242b6a 100644
--- a/cpp/src/Ice/ConnectionFactory.cpp
+++ b/cpp/src/Ice/ConnectionFactory.cpp
@@ -1603,7 +1603,7 @@ IceInternal::IncomingConnectionFactory::connectionStartFailed(const Ice::Connect
//
IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const InstancePtr& instance,
const EndpointIPtr& endpoint,
- const ObjectAdapterPtr& adapter) :
+ const ObjectAdapterIPtr& adapter) :
_instance(instance),
_monitor(new FactoryACMMonitor(instance, dynamic_cast<ObjectAdapterI*>(adapter.get())->getACM())),
_endpoint(endpoint),
@@ -1664,7 +1664,7 @@ IceInternal::IncomingConnectionFactory::initialize(const string& oaName)
out << "listening for " << _endpoint->protocol() << " connections\n" << _acceptor->toDetailedString();
}
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->initialize(this);
+ _adapter->getThreadPool()->initialize(this);
}
}
catch(const Ice::Exception&)
@@ -1730,7 +1730,7 @@ IceInternal::IncomingConnectionFactory::setState(State state)
Trace out(_instance->initializationData().logger, _instance->traceLevels()->networkCat);
out << "accepting " << _endpoint->protocol() << " connections at " << _acceptor->toString();
}
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->_register(this, SocketOperationRead);
+ _adapter->getThreadPool()->_register(this, SocketOperationRead);
}
for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::activate));
break;
@@ -1749,7 +1749,7 @@ IceInternal::IncomingConnectionFactory::setState(State state)
Trace out(_instance->initializationData().logger, _instance->traceLevels()->networkCat);
out << "holding " << _endpoint->protocol() << " connections at " << _acceptor->toString();
}
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->unregister(this, SocketOperationRead);
+ _adapter->getThreadPool()->unregister(this, SocketOperationRead);
}
for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::hold));
break;
@@ -1766,7 +1766,7 @@ IceInternal::IncomingConnectionFactory::setState(State state)
// the finish() call. Not all selector implementations do support this
// however.
//
- if(dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->finish(this, true))
+ if(_adapter->getThreadPool()->finish(this, true))
{
closeAcceptor(true);
}
diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h
index c6b688225b5..1026027d87e 100644
--- a/cpp/src/Ice/ConnectionFactory.h
+++ b/cpp/src/Ice/ConnectionFactory.h
@@ -36,6 +36,7 @@ namespace Ice
class LocalException;
class ObjectAdapterI;
+typedef IceUtil::Handle<ObjectAdapterI> ObjectAdapterIPtr;
}
@@ -199,7 +200,7 @@ public:
private:
- IncomingConnectionFactory(const InstancePtr&, const EndpointIPtr&, const Ice::ObjectAdapterPtr&);
+ IncomingConnectionFactory(const InstancePtr&, const EndpointIPtr&, const Ice::ObjectAdapterIPtr&);
void initialize(const std::string&);
virtual ~IncomingConnectionFactory();
friend class Ice::ObjectAdapterI;
@@ -222,7 +223,7 @@ private:
const TransceiverPtr _transceiver;
const EndpointIPtr _endpoint;
- Ice::ObjectAdapterPtr _adapter;
+ Ice::ObjectAdapterIPtr _adapter;
const bool _warn;
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index 36bb80fc952..2a3077aa7b8 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -1845,9 +1845,9 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current)
{
throw IllegalMessageSizeException(__FILE__, __LINE__);
}
- if(size > static_cast<Int>(_instance->messageSizeMax()))
+ if(size > static_cast<Int>(_messageSizeMax))
{
- Ex::throwMemoryLimitException(__FILE__, __LINE__, size, _instance->messageSizeMax());
+ Ex::throwMemoryLimitException(__FILE__, __LINE__, size, _messageSizeMax);
}
if(size > static_cast<Int>(_readStream.b.size()))
{
@@ -2380,7 +2380,7 @@ Ice::ConnectionI::ConnectionI(const CommunicatorPtr& communicator,
const TransceiverPtr& transceiver,
const ConnectorPtr& connector,
const EndpointIPtr& endpoint,
- const ObjectAdapterPtr& adapter) :
+ const ObjectAdapterIPtr& adapter) :
_communicator(communicator),
_instance(instance),
_monitor(monitor),
@@ -2404,6 +2404,7 @@ Ice::ConnectionI::ConnectionI(const CommunicatorPtr& communicator,
_nextRequestId(1),
_requestsHint(_requests.end()),
_asyncRequestsHint(_asyncRequests.end()),
+ _messageSizeMax(adapter ? adapter->messageSizeMax() : _instance->messageSizeMax()),
_batchAutoFlushSize(_instance->batchAutoFlushSize()),
_batchStream(_instance.get(), Ice::currentProtocolEncoding),
_batchStreamInUse(false),
@@ -2432,10 +2433,9 @@ Ice::ConnectionI::ConnectionI(const CommunicatorPtr& communicator,
compressionLevel = 9;
}
- ObjectAdapterI* adapterImpl = _adapter ? dynamic_cast<ObjectAdapterI*>(_adapter.get()) : 0;
- if(adapterImpl)
+ if(adapter)
{
- _servantManager = adapterImpl->getServantManager();
+ _servantManager = adapter->getServantManager();
}
if(_monitor && _monitor->getACM().timeout > 0)
@@ -2446,9 +2446,9 @@ Ice::ConnectionI::ConnectionI(const CommunicatorPtr& communicator,
__setNoDelete(true);
try
{
- if(adapterImpl)
+ if(adapter)
{
- const_cast<ThreadPoolPtr&>(_threadPool) = adapterImpl->getThreadPool();
+ const_cast<ThreadPoolPtr&>(_threadPool) = adapter->getThreadPool();
}
else
{
@@ -3380,9 +3380,9 @@ Ice::ConnectionI::doUncompress(BasicStream& compressed, BasicStream& uncompresse
throw IllegalMessageSizeException(__FILE__, __LINE__);
}
- if(uncompressedSize > static_cast<Int>(_instance->messageSizeMax()))
+ if(uncompressedSize > static_cast<Int>(_messageSizeMax))
{
- Ex::throwMemoryLimitException(__FILE__, __LINE__, uncompressedSize, _instance->messageSizeMax());
+ Ex::throwMemoryLimitException(__FILE__, __LINE__, uncompressedSize, _messageSizeMax);
}
uncompressed.resize(uncompressedSize);
diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h
index 6432863185c..003ef41c519 100644
--- a/cpp/src/Ice/ConnectionI.h
+++ b/cpp/src/Ice/ConnectionI.h
@@ -52,6 +52,8 @@ namespace Ice
{
class LocalException;
+class ObjectAdapterI;
+typedef IceUtil::Handle<ObjectAdapterI> ObjectAdapterIPtr;
class ConnectionI : public Connection,
public IceInternal::EventHandler,
@@ -247,7 +249,7 @@ private:
ConnectionI(const Ice::CommunicatorPtr&, const IceInternal::InstancePtr&, const IceInternal::ACMMonitorPtr&,
const IceInternal::TransceiverPtr&, const IceInternal::ConnectorPtr&,
- const IceInternal::EndpointIPtr&, const ObjectAdapterPtr&);
+ const IceInternal::EndpointIPtr&, const ObjectAdapterIPtr&);
virtual ~ConnectionI();
friend class IceInternal::IncomingConnectionFactory;
@@ -331,6 +333,7 @@ private:
IceUtil::UniquePtr<LocalException> _exception;
+ const size_t _messageSizeMax;
const size_t _batchAutoFlushSize;
IceInternal::BasicStream _batchStream;
bool _batchStreamInUse;
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 11d27fc1111..5f9034be027 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -1260,11 +1260,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
{
static const int defaultMessageSizeMax = 1024;
Int num = _initData.properties->getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
- if(num < 1)
- {
- const_cast<size_t&>(_messageSizeMax) = defaultMessageSizeMax * 1024; // Ignore non-sensical values.
- }
- else if(static_cast<size_t>(num) > static_cast<size_t>(0x7fffffff / 1024))
+ if(num < 1 || static_cast<size_t>(num) > static_cast<size_t>(0x7fffffff / 1024))
{
const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(0x7fffffff);
}
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 537aab5f79d..2fd1f92d10f 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -858,7 +858,8 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
_servantManager(new ServantManager(instance, name)),
_name(name),
_directCount(0),
- _noConfig(noConfig)
+ _noConfig(noConfig),
+ _messageSizeMax(0)
{
}
@@ -923,6 +924,19 @@ Ice::ObjectAdapterI::initialize(const RouterPrx& router)
const_cast<ACMConfig&>(_acm) =
ACMConfig(properties, _communicator->getLogger(), _name + ".ACM", _instance->serverACM());
+ {
+ const int defaultMessageSizeMax = _instance->messageSizeMax() / 1024;
+ Int num = properties->getPropertyAsIntWithDefault(_name + ".MessageSizeMax", defaultMessageSizeMax);
+ if(num < 1 || static_cast<size_t>(num) > static_cast<size_t>(0x7fffffff / 1024))
+ {
+ const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(0x7fffffff);
+ }
+ else
+ {
+ const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(num) * 1024;
+ }
+ }
+
int threadPoolSize = properties->getPropertyAsInt(_name + ".ThreadPool.Size");
int threadPoolSizeMax = properties->getPropertyAsInt(_name + ".ThreadPool.SizeMax");
bool hasPriority = properties->getProperty(_name + ".ThreadPool.ThreadPriority") != "";
@@ -1415,6 +1429,7 @@ Ice::ObjectAdapterI::filterProperties(StringSeq& unknownProps)
"Locator.PreferSecure",
"Locator.CollocationOptimized",
"Locator.Router",
+ "MessageSizeMax",
"PublishedEndpoints",
"RegisterProcess",
"ReplicaGroupId",
diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h
index a1f8711c068..25bf9830864 100644
--- a/cpp/src/Ice/ObjectAdapterI.h
+++ b/cpp/src/Ice/ObjectAdapterI.h
@@ -98,6 +98,7 @@ public:
IceInternal::ThreadPoolPtr getThreadPool() const;
IceInternal::ServantManagerPtr getServantManager() const;
IceInternal::ACMConfig getACM() const;
+ size_t messageSizeMax() const { return _messageSizeMax; }
private:
@@ -146,6 +147,7 @@ private:
int _directCount; // The number of direct proxies dispatching on this object adapter.
bool _noConfig;
Identity _processId;
+ size_t _messageSizeMax;
};
}
diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp
index e49f0cf49bf..5d3a73e24a7 100644
--- a/cpp/src/IceGrid/RegistryI.cpp
+++ b/cpp/src/IceGrid/RegistryI.cpp
@@ -242,6 +242,10 @@ RegistryI::startImpl()
properties->setProperty("IceGrid.Registry.SessionManager.AdapterId", "");
properties->setProperty("IceGrid.Registry.AdminSessionManager.AdapterId", "");
properties->setProperty("IceGrid.Registry.Internal.AdapterId", "");
+ if(properties->getProperty("IceGrid.Registry.Internal.MessageSizeMax").empty())
+ {
+ properties->setProperty("IceGrid.Registry.Internal.MessageSizeMax", "0"); // No limit on internal data exchanged
+ }
setupThreadPool(properties, "IceGrid.Registry.Client.ThreadPool", 1, 10);
setupThreadPool(properties, "IceGrid.Registry.Server.ThreadPool", 1, 10, true); // Serialize for admin callbacks
diff --git a/cpp/src/IceStorm/Service.cpp b/cpp/src/IceStorm/Service.cpp
index 376277e9f93..0be7c03f06c 100644
--- a/cpp/src/IceStorm/Service.cpp
+++ b/cpp/src/IceStorm/Service.cpp
@@ -331,6 +331,10 @@ ServiceI::start(
properties->setProperty(name + ".Node.ThreadPool.Size", os.str());
properties->setProperty(name + ".Node.ThreadPool.SizeWarn", "0");
}
+ if(properties->getProperty(name + ".Node.MessageSizeMax").empty())
+ {
+ properties->setProperty(name + ".Node.MessageSizeMax", 0); // No limit on data exchanged internally
+ }
Ice::ObjectAdapterPtr nodeAdapter = communicator->createObjectAdapter(name + ".Node");
_instance = new Instance(instanceName, name, communicator, publishAdapter, topicAdapter,
diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp
index f03bdab60b5..13845097f8b 100644
--- a/cpp/test/Ice/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/exceptions/AllTests.cpp
@@ -932,10 +932,30 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::ConnectionLostException&)
{
}
- catch(...)
+ catch(const Ice::LocalException& ex)
+ {
+ cerr << ex << endl;
+ test(false);
+ }
+
+ ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(communicator->stringToProxy("thrower:default -p 12011"));
+ try
+ {
+ thrower2->throwMemoryLimitException(Ice::ByteSeq(2 * 1024 * 1024)); // 2MB (no limits)
+ }
+ catch(const Ice::MemoryLimitException&)
+ {
+ }
+ ThrowerPrx thrower3 = ThrowerPrx::uncheckedCast(communicator->stringToProxy("thrower:default -p 12012"));
+ try
{
+ thrower3->throwMemoryLimitException(Ice::ByteSeq(1024)); // 1KB limit
test(false);
}
+ catch(const Ice::ConnectionLostException&)
+ {
+ }
+
cout << "ok" << endl;
}
diff --git a/cpp/test/Ice/exceptions/Server.cpp b/cpp/test/Ice/exceptions/Server.cpp
index d50ffc78dd6..32706ccaf8b 100644
--- a/cpp/test/Ice/exceptions/Server.cpp
+++ b/cpp/test/Ice/exceptions/Server.cpp
@@ -19,9 +19,15 @@ int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
+ Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("TestAdapter2");
+ Ice::ObjectAdapterPtr adapter3 = communicator->createObjectAdapter("TestAdapter3");
Ice::ObjectPtr object = new ThrowerI();
adapter->add(object, communicator->stringToIdentity("thrower"));
+ adapter2->add(object, communicator->stringToIdentity("thrower"));
+ adapter3->add(object, communicator->stringToIdentity("thrower"));
adapter->activate();
+ adapter2->activate();
+ adapter3->activate();
TEST_READY
communicator->waitForShutdown();
return EXIT_SUCCESS;
@@ -41,6 +47,10 @@ main(int argc, char* argv[])
initData.properties->setProperty("Ice.Warn.Connections", "0");
initData.properties->setProperty("TestAdapter.Endpoints", "default -p 12010:udp");
initData.properties->setProperty("Ice.MessageSizeMax", "10"); // 10KB max
+ initData.properties->setProperty("TestAdapter2.Endpoints", "default -p 12011");
+ initData.properties->setProperty("TestAdapter2.MessageSizeMax", "0");
+ initData.properties->setProperty("TestAdapter3.Endpoints", "default -p 12012");
+ initData.properties->setProperty("TestAdapter3.MessageSizeMax", "1");
communicator = Ice::initialize(argc, argv, initData);
status = run(argc, argv, communicator);
}
diff --git a/cpp/test/Ice/exceptions/ServerAMD.cpp b/cpp/test/Ice/exceptions/ServerAMD.cpp
index 04f4d5805bc..75de52d1efb 100644
--- a/cpp/test/Ice/exceptions/ServerAMD.cpp
+++ b/cpp/test/Ice/exceptions/ServerAMD.cpp
@@ -19,9 +19,15 @@ int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
+ Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("TestAdapter2");
+ Ice::ObjectAdapterPtr adapter3 = communicator->createObjectAdapter("TestAdapter3");
Ice::ObjectPtr object = new ThrowerI();
adapter->add(object, communicator->stringToIdentity("thrower"));
+ adapter2->add(object, communicator->stringToIdentity("thrower"));
+ adapter3->add(object, communicator->stringToIdentity("thrower"));
adapter->activate();
+ adapter2->activate();
+ adapter3->activate();
TEST_READY
communicator->waitForShutdown();
return EXIT_SUCCESS;
@@ -41,6 +47,10 @@ main(int argc, char* argv[])
initData.properties->setProperty("Ice.Warn.Connections", "0");
initData.properties->setProperty("TestAdapter.Endpoints", "default -p 12010:udp");
initData.properties->setProperty("Ice.MessageSizeMax", "10"); // 10KB max
+ initData.properties->setProperty("TestAdapter2.Endpoints", "default -p 12011");
+ initData.properties->setProperty("TestAdapter2.MessageSizeMax", "0");
+ initData.properties->setProperty("TestAdapter3.Endpoints", "default -p 12012");
+ initData.properties->setProperty("TestAdapter3.MessageSizeMax", "1");
communicator = Ice::initialize(argc, argv, initData);
status = run(argc, argv, communicator);
}
diff --git a/cs/src/Ice/BasicStream.cs b/cs/src/Ice/BasicStream.cs
index 3ce5b71c121..8e8c1b7149f 100644
--- a/cs/src/Ice/BasicStream.cs
+++ b/cs/src/Ice/BasicStream.cs
@@ -3383,7 +3383,7 @@ namespace IceInternal
#endif
}
- public BasicStream uncompress(int headerSize)
+ public BasicStream uncompress(int headerSize, int messageSizeMax)
{
#if MANAGED || COMPACT || SILVERLIGHT
return this;
@@ -3399,9 +3399,9 @@ namespace IceInternal
{
throw new Ice.IllegalMessageSizeException("compressed size <= header size");
}
- if(uncompressedSize > instance_.messageSizeMax())
+ if(uncompressedSize > messageSizeMax)
{
- IceInternal.Ex.throwMemoryLimitException(uncompressedSize, instance_.messageSizeMax());
+ IceInternal.Ex.throwMemoryLimitException(uncompressedSize, messageSizeMax);
}
int compressedLen = size() - headerSize - 4;
diff --git a/cs/src/Ice/ConnectionFactory.cs b/cs/src/Ice/ConnectionFactory.cs
index 88cbb58d094..28f0701b0cf 100644
--- a/cs/src/Ice/ConnectionFactory.cs
+++ b/cs/src/Ice/ConnectionFactory.cs
@@ -1676,7 +1676,7 @@ namespace IceInternal
}
}
- public IncomingConnectionFactory(Instance instance, EndpointI endpoint, Ice.ObjectAdapter adapter,
+ public IncomingConnectionFactory(Instance instance, EndpointI endpoint, Ice.ObjectAdapterI adapter,
string adapterName)
{
_instance = instance;
@@ -1742,7 +1742,7 @@ namespace IceInternal
_instance.initializationData().logger.trace(_instance.traceLevels().networkCat, s.ToString());
}
- ((Ice.ObjectAdapterI)_adapter).getThreadPool().initialize(this);
+ _adapter.getThreadPool().initialize(this);
}
}
catch(System.Exception ex)
@@ -1820,7 +1820,7 @@ namespace IceInternal
_instance.initializationData().logger.trace(_instance.traceLevels().networkCat,
s.ToString());
}
- ((Ice.ObjectAdapterI)_adapter).getThreadPool().register(this, SocketOperation.Read);
+ _adapter.getThreadPool().register(this, SocketOperation.Read);
}
foreach(Ice.ConnectionI connection in _connections)
@@ -1847,7 +1847,7 @@ namespace IceInternal
_instance.initializationData().logger.trace(_instance.traceLevels().networkCat,
s.ToString());
}
- ((Ice.ObjectAdapterI)_adapter).getThreadPool().unregister(this, SocketOperation.Read);
+ _adapter.getThreadPool().unregister(this, SocketOperation.Read);
}
foreach(Ice.ConnectionI connection in _connections)
@@ -1861,7 +1861,7 @@ namespace IceInternal
{
if(_acceptor != null)
{
- ((Ice.ObjectAdapterI)_adapter).getThreadPool().finish(this);
+ _adapter.getThreadPool().finish(this);
closeAcceptor(true);
}
else
@@ -1913,7 +1913,7 @@ namespace IceInternal
private readonly Transceiver _transceiver;
private EndpointI _endpoint;
- private Ice.ObjectAdapter _adapter;
+ private Ice.ObjectAdapterI _adapter;
private readonly bool _warn;
diff --git a/cs/src/Ice/ConnectionI.cs b/cs/src/Ice/ConnectionI.cs
index 11a3ba0fe84..5a5b02bd6ed 100644
--- a/cs/src/Ice/ConnectionI.cs
+++ b/cs/src/Ice/ConnectionI.cs
@@ -1258,9 +1258,9 @@ namespace Ice
{
throw new Ice.IllegalMessageSizeException();
}
- if(size > _instance.messageSizeMax())
+ if(size > _messageSizeMax)
{
- IceInternal.Ex.throwMemoryLimitException(size, _instance.messageSizeMax());
+ IceInternal.Ex.throwMemoryLimitException(size, _messageSizeMax);
}
if(size > _readStream.size())
{
@@ -1772,7 +1772,7 @@ namespace Ice
internal ConnectionI(Communicator communicator, IceInternal.Instance instance,
IceInternal.ACMMonitor monitor, IceInternal.Transceiver transceiver,
- IceInternal.Connector connector, IceInternal.EndpointI endpoint, ObjectAdapter adapter)
+ IceInternal.Connector connector, IceInternal.EndpointI endpoint, ObjectAdapterI adapter)
{
_communicator = communicator;
_instance = instance;
@@ -1803,6 +1803,7 @@ namespace Ice
_acmLastActivity = -1;
}
_nextRequestId = 1;
+ _messageSizeMax = adapter != null ? adapter.messageSizeMax() : instance.messageSizeMax();
_batchAutoFlushSize = instance.batchAutoFlushSize();
_batchStream = new IceInternal.BasicStream(instance, Util.currentProtocolEncoding);
_batchStreamInUse = false;
@@ -1827,17 +1828,16 @@ namespace Ice
_compressionLevel = 9;
}
- ObjectAdapterI adapterImpl = _adapter as ObjectAdapterI;
- if(adapterImpl != null)
+ if(adapter != null)
{
- _servantManager = adapterImpl.getServantManager();
+ _servantManager = adapter.getServantManager();
}
try
{
- if(adapterImpl != null)
+ if(adapter != null)
{
- _threadPool = adapterImpl.getThreadPool();
+ _threadPool = adapter.getThreadPool();
}
else
{
@@ -2605,7 +2605,7 @@ namespace Ice
{
if(_compressionSupported)
{
- info.stream = info.stream.uncompress(IceInternal.Protocol.headerSize);
+ info.stream = info.stream.uncompress(IceInternal.Protocol.headerSize, _messageSizeMax);
}
else
{
@@ -3170,7 +3170,8 @@ namespace Ice
private LocalException _exception;
- private int _batchAutoFlushSize;
+ private readonly int _messageSizeMax;
+ private readonly int _batchAutoFlushSize;
private IceInternal.BasicStream _batchStream;
private bool _batchStreamInUse;
private int _batchRequestNum;
diff --git a/cs/src/Ice/Instance.cs b/cs/src/Ice/Instance.cs
index afaa0132fa7..4f37787d5b8 100644
--- a/cs/src/Ice/Instance.cs
+++ b/cs/src/Ice/Instance.cs
@@ -816,11 +816,7 @@ namespace IceInternal
const int defaultMessageSizeMax = 1024;
int num =
_initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
- if(num < 1)
- {
- _messageSizeMax = defaultMessageSizeMax * 1024; // Ignore non-sensical values.
- }
- else if(num > 0x7fffffff / 1024)
+ if(num < 1 || num > 0x7fffffff / 1024)
{
_messageSizeMax = 0x7fffffff;
}
diff --git a/cs/src/Ice/ObjectAdapterI.cs b/cs/src/Ice/ObjectAdapterI.cs
index 80ee0d831f9..e8defa337df 100644
--- a/cs/src/Ice/ObjectAdapterI.cs
+++ b/cs/src/Ice/ObjectAdapterI.cs
@@ -803,6 +803,12 @@ namespace Ice
return _acm;
}
+ public int messageSizeMax()
+ {
+ // No mutex lock, immutable.
+ return _messageSizeMax;
+ }
+
//
// Only for use by ObjectAdapterFactory
//
@@ -888,8 +894,20 @@ namespace Ice
throw ex;
}
- _acm = new ACMConfig(properties, communicator.getLogger(), _name + ".ACM",
- instance_.serverACM());
+ _acm = new ACMConfig(properties, communicator.getLogger(), _name + ".ACM", instance_.serverACM());
+
+ {
+ int defaultMessageSizeMax = instance.messageSizeMax() / 1024;
+ int num = properties.getPropertyAsIntWithDefault(_name + ".MessageSizeMax", defaultMessageSizeMax);
+ if(num < 1 || num > 0x7fffffff / 1024)
+ {
+ _messageSizeMax = 0x7fffffff;
+ }
+ else
+ {
+ _messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes
+ }
+ }
try
{
@@ -1460,6 +1478,7 @@ namespace Ice
"Locator.PreferSecure",
"Locator.CollocationOptimized",
"Locator.Router",
+ "MessageSizeMax",
"PublishedEndpoints",
"RegisterProcess",
"ReplicaGroupId",
@@ -1555,5 +1574,6 @@ namespace Ice
private int _directCount; // The number of direct proxies dispatching on this object adapter.
private bool _noConfig;
private Identity _processId;
+ private int _messageSizeMax;
}
}
diff --git a/cs/test/Ice/exceptions/AllTests.cs b/cs/test/Ice/exceptions/AllTests.cs
index 6c7d4f41f64..fa8c0354e09 100644
--- a/cs/test/Ice/exceptions/AllTests.cs
+++ b/cs/test/Ice/exceptions/AllTests.cs
@@ -460,6 +460,27 @@ public class AllTests : TestCommon.TestApp
{
test(false);
}
+
+ ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(
+ communicator.stringToProxy("thrower:default -p 12011"));
+ try
+ {
+ thrower2.throwMemoryLimitException(new byte[2 * 1024 * 1024]); // 2MB (no limits)
+ }
+ catch(Ice.MemoryLimitException)
+ {
+ }
+ ThrowerPrx thrower3 = ThrowerPrxHelper.uncheckedCast(
+ communicator.stringToProxy("thrower:default -p 12012"));
+ try
+ {
+ thrower3.throwMemoryLimitException(new byte[1024]); // 1KB limit
+ test(false);
+ }
+ catch(Ice.ConnectionLostException)
+ {
+ }
+
WriteLine("ok");
}
diff --git a/cs/test/Ice/exceptions/Server.cs b/cs/test/Ice/exceptions/Server.cs
index bf219e4228c..2880a72e557 100644
--- a/cs/test/Ice/exceptions/Server.cs
+++ b/cs/test/Ice/exceptions/Server.cs
@@ -51,9 +51,15 @@ public class Server
private static int run(string[] args, Ice.Communicator communicator)
{
Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
- Ice.Object @object = new ThrowerI();
- adapter.add(@object, communicator.stringToIdentity("thrower"));
+ Ice.ObjectAdapter adapter2 = communicator.createObjectAdapter("TestAdapter2");
+ Ice.ObjectAdapter adapter3 = communicator.createObjectAdapter("TestAdapter3");
+ Ice.Object obj = new ThrowerI();
+ adapter.add(obj, communicator.stringToIdentity("thrower"));
+ adapter2.add(obj, communicator.stringToIdentity("thrower"));
+ adapter3.add(obj, communicator.stringToIdentity("thrower"));
adapter.activate();
+ adapter2.activate();
+ adapter3.activate();
communicator.waitForShutdown();
return 0;
}
@@ -71,6 +77,11 @@ public class Server
initData.properties.setProperty("Ice.Warn.Connections", "0");
initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp");
initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max
+ initData.properties.setProperty("TestAdapter2.Endpoints", "default -p 12011");
+ initData.properties.setProperty("TestAdapter2.MessageSizeMax", "0");
+ initData.properties.setProperty("TestAdapter3.Endpoints", "default -p 12012");
+ initData.properties.setProperty("TestAdapter3.MessageSizeMax", "1");
+
communicator = Ice.Util.initialize(ref args, initData);
status = run(args, communicator);
}
diff --git a/java/src/Ice/src/main/java/Ice/ConnectionI.java b/java/src/Ice/src/main/java/Ice/ConnectionI.java
index cfef2312b11..57ec2b58b49 100644
--- a/java/src/Ice/src/main/java/Ice/ConnectionI.java
+++ b/java/src/Ice/src/main/java/Ice/ConnectionI.java
@@ -1103,9 +1103,9 @@ public final class ConnectionI extends IceInternal.EventHandler
{
throw new Ice.IllegalMessageSizeException();
}
- if(size > _instance.messageSizeMax())
+ if(size > _messageSizeMax)
{
- IceInternal.Ex.throwMemoryLimitException(size, _instance.messageSizeMax());
+ IceInternal.Ex.throwMemoryLimitException(size, _messageSizeMax);
}
if(size > _readStream.size())
{
@@ -1625,8 +1625,8 @@ public final class ConnectionI extends IceInternal.EventHandler
}
public ConnectionI(Communicator communicator, IceInternal.Instance instance, IceInternal.ACMMonitor monitor,
- IceInternal.Transceiver transceiver, IceInternal.Connector connector, IceInternal.EndpointI endpoint,
- ObjectAdapter adapter)
+ IceInternal.Transceiver transceiver, IceInternal.Connector connector,
+ IceInternal.EndpointI endpoint, ObjectAdapterI adapter)
{
_communicator = communicator;
_instance = instance;
@@ -1659,6 +1659,7 @@ public final class ConnectionI extends IceInternal.EventHandler
_acmLastActivity = -1;
}
_nextRequestId = 1;
+ _messageSizeMax = adapter != null ? adapter.messageSizeMax() : instance.messageSizeMax();
_batchAutoFlushSize = _instance.batchAutoFlushSize();
_batchStream = new IceInternal.BasicStream(instance, IceInternal.Protocol.currentProtocolEncoding);
_batchStreamInUse = false;
@@ -1684,9 +1685,9 @@ public final class ConnectionI extends IceInternal.EventHandler
}
_compressionLevel = compressionLevel;
- if(_adapter != null)
+ if(adapter != null)
{
- _servantManager = ((ObjectAdapterI) _adapter).getServantManager();
+ _servantManager = adapter.getServantManager();
}
else
{
@@ -1695,9 +1696,9 @@ public final class ConnectionI extends IceInternal.EventHandler
try
{
- if(_adapter != null)
+ if(adapter != null)
{
- _threadPool = ((ObjectAdapterI) _adapter).getThreadPool();
+ _threadPool = adapter.getThreadPool();
}
else
{
@@ -2518,7 +2519,7 @@ public final class ConnectionI extends IceInternal.EventHandler
{
if(IceInternal.BasicStream.compressible())
{
- info.stream = info.stream.uncompress(IceInternal.Protocol.headerSize);
+ info.stream = info.stream.uncompress(IceInternal.Protocol.headerSize, _messageSizeMax);
}
else
{
@@ -3120,7 +3121,8 @@ public final class ConnectionI extends IceInternal.EventHandler
private LocalException _exception;
- private int _batchAutoFlushSize;
+ private final int _messageSizeMax;
+ private final int _batchAutoFlushSize;
private IceInternal.BasicStream _batchStream;
private boolean _batchStreamInUse;
private int _batchRequestNum;
diff --git a/java/src/Ice/src/main/java/Ice/ObjectAdapterI.java b/java/src/Ice/src/main/java/Ice/ObjectAdapterI.java
index 9837175bccc..d00a347731a 100644
--- a/java/src/Ice/src/main/java/Ice/ObjectAdapterI.java
+++ b/java/src/Ice/src/main/java/Ice/ObjectAdapterI.java
@@ -857,6 +857,13 @@ public final class ObjectAdapterI implements ObjectAdapter
return _acm;
}
+ public int
+ messageSizeMax()
+ {
+ // No mutex lock, immutable.
+ return _messageSizeMax;
+ }
+
//
// Only for use by IceInternal.ObjectAdapterFactory
//
@@ -879,6 +886,7 @@ public final class ObjectAdapterI implements ObjectAdapter
_replicaGroupId = "";
_reference = _instance.referenceFactory().create("dummy -t", "");
_acm = _instance.serverACM();
+ _messageSizeMax = _instance.messageSizeMax();
return;
}
@@ -940,6 +948,19 @@ public final class ObjectAdapterI implements ObjectAdapter
_acm = new IceInternal.ACMConfig(properties, communicator.getLogger(), _name + ".ACM", instance.serverACM());
+ {
+ final int defaultMessageSizeMax = instance.messageSizeMax() / 1024;
+ int num = properties.getPropertyAsIntWithDefault(_name + ".MessageSizeMax", defaultMessageSizeMax);
+ if(num < 1 || num > 0x7fffffff / 1024)
+ {
+ _messageSizeMax = 0x7fffffff;
+ }
+ else
+ {
+ _messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes
+ }
+ }
+
try
{
int threadPoolSize = properties.getPropertyAsInt(_name + ".ThreadPool.Size");
@@ -1519,6 +1540,7 @@ public final class ObjectAdapterI implements ObjectAdapter
"Locator.PreferSecure",
"Locator.CollocationOptimized",
"Locator.Router",
+ "MessageSizeMax",
"PublishedEndpoints",
"RegisterProcess",
"ReplicaGroupId",
@@ -1614,4 +1636,5 @@ public final class ObjectAdapterI implements ObjectAdapter
private int _directCount; // The number of direct proxies dispatching on this object adapter.
private boolean _noConfig;
private Identity _processId = null;
+ private final int _messageSizeMax;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/BasicStream.java b/java/src/Ice/src/main/java/IceInternal/BasicStream.java
index 82d84110cb9..58620c59170 100644
--- a/java/src/Ice/src/main/java/IceInternal/BasicStream.java
+++ b/java/src/Ice/src/main/java/IceInternal/BasicStream.java
@@ -1,4 +1,3 @@
-
// **********************************************************************
//
// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
@@ -2637,7 +2636,7 @@ public class BasicStream
}
public BasicStream
- uncompress(int headerSize)
+ uncompress(int headerSize, int messageSizeMax)
{
assert(compressible());
@@ -2647,9 +2646,9 @@ public class BasicStream
{
throw new Ice.IllegalMessageSizeException();
}
- if(uncompressedSize > _instance.messageSizeMax())
+ if(uncompressedSize > messageSizeMax)
{
- IceInternal.Ex.throwMemoryLimitException(uncompressedSize, _instance.messageSizeMax());
+ IceInternal.Ex.throwMemoryLimitException(uncompressedSize, messageSizeMax);
}
int compressedLen = size() - headerSize - 4;
diff --git a/java/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java b/java/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java
index e1d3daa6b18..e0a62027edf 100644
--- a/java/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java
+++ b/java/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java
@@ -363,14 +363,14 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice
}
public
- IncomingConnectionFactory(Instance instance, EndpointI endpoint, Ice.ObjectAdapter adapter, String adapterName)
+ IncomingConnectionFactory(Instance instance, EndpointI endpoint, Ice.ObjectAdapterI adapter, String adapterName)
{
_instance = instance;
_endpoint = endpoint;
_adapter = adapter;
_warn = _instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Connections") > 0 ? true : false;
_state = StateHolding;
- _monitor = new FactoryACMMonitor(instance, ((Ice.ObjectAdapterI)adapter).getACM());
+ _monitor = new FactoryACMMonitor(instance, adapter.getACM());
DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
if(defaultsAndOverrides.overrideTimeout)
@@ -430,7 +430,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice
_instance.initializationData().logger.trace(_instance.traceLevels().networkCat, s.toString());
}
- ((Ice.ObjectAdapterI)_adapter).getThreadPool().initialize(this);
+ _adapter.getThreadPool().initialize(this);
}
}
catch(java.lang.Exception ex)
@@ -531,7 +531,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice
s.append(_acceptor.toString());
_instance.initializationData().logger.trace(_instance.traceLevels().networkCat, s.toString());
}
- ((Ice.ObjectAdapterI)_adapter).getThreadPool().register(this, SocketOperation.Read);
+ _adapter.getThreadPool().register(this, SocketOperation.Read);
}
for(Ice.ConnectionI connection : _connections)
@@ -557,7 +557,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice
s.append(_acceptor.toString());
_instance.initializationData().logger.trace(_instance.traceLevels().networkCat, s.toString());
}
- ((Ice.ObjectAdapterI)_adapter).getThreadPool().unregister(this, SocketOperation.Read);
+ _adapter.getThreadPool().unregister(this, SocketOperation.Read);
}
for(Ice.ConnectionI connection : _connections)
@@ -577,7 +577,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice
// if there are no more threads in the thread pool available to dispatch
// the finish() call.
//
- if(((Ice.ObjectAdapterI)_adapter).getThreadPool().finish(this, true))
+ if(_adapter.getThreadPool().finish(this, true))
{
closeAcceptor(true);
}
@@ -633,7 +633,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice
private Transceiver _transceiver;
private EndpointI _endpoint;
- private Ice.ObjectAdapter _adapter;
+ private Ice.ObjectAdapterI _adapter;
private final boolean _warn;
diff --git a/java/src/Ice/src/main/java/IceInternal/Instance.java b/java/src/Ice/src/main/java/IceInternal/Instance.java
index 8085635ad04..ebe7dd118df 100644
--- a/java/src/Ice/src/main/java/IceInternal/Instance.java
+++ b/java/src/Ice/src/main/java/IceInternal/Instance.java
@@ -892,11 +892,7 @@ public final class Instance
{
final int defaultMessageSizeMax = 1024;
int num = _initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
- if(num < 1)
- {
- _messageSizeMax = defaultMessageSizeMax * 1024; // Ignore non-sensical values.
- }
- else if(num > 0x7fffffff / 1024)
+ if(num < 1 || num > 0x7fffffff / 1024)
{
_messageSizeMax = 0x7fffffff;
}
diff --git a/java/test/src/main/java/test/Ice/exceptions/AMDServer.java b/java/test/src/main/java/test/Ice/exceptions/AMDServer.java
index 2863c0fa5dc..0ee384ac865 100644
--- a/java/test/src/main/java/test/Ice/exceptions/AMDServer.java
+++ b/java/test/src/main/java/test/Ice/exceptions/AMDServer.java
@@ -16,9 +16,15 @@ public class AMDServer extends test.Util.Application
{
Ice.Communicator communicator = communicator();
Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
- Ice.Object object = new AMDThrowerI();
+ Ice.ObjectAdapter adapter2 = communicator.createObjectAdapter("TestAdapter2");
+ Ice.ObjectAdapter adapter3 = communicator.createObjectAdapter("TestAdapter3");
+ Ice.Object object = new ThrowerI();
adapter.add(object, communicator.stringToIdentity("thrower"));
+ adapter2.add(object, communicator.stringToIdentity("thrower"));
+ adapter3.add(object, communicator.stringToIdentity("thrower"));
adapter.activate();
+ adapter2.activate();
+ adapter3.activate();
return WAIT;
}
@@ -38,6 +44,10 @@ public class AMDServer extends test.Util.Application
initData.properties.setProperty("Ice.Package.Test", "test.Ice.exceptions.AMD");
initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp");
initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max
+ initData.properties.setProperty("TestAdapter2.Endpoints", "default -p 12011");
+ initData.properties.setProperty("TestAdapter2.MessageSizeMax", "0");
+ initData.properties.setProperty("TestAdapter3.Endpoints", "default -p 12012");
+ initData.properties.setProperty("TestAdapter3.MessageSizeMax", "1");
return initData;
}
diff --git a/java/test/src/main/java/test/Ice/exceptions/AllTests.java b/java/test/src/main/java/test/Ice/exceptions/AllTests.java
index e66e96cbda5..c9ff44cab46 100644
--- a/java/test/src/main/java/test/Ice/exceptions/AllTests.java
+++ b/java/test/src/main/java/test/Ice/exceptions/AllTests.java
@@ -1134,6 +1134,27 @@ public class AllTests
ex.printStackTrace();
test(false);
}
+
+ ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(
+ communicator.stringToProxy("thrower:default -p 12011"));
+ try
+ {
+ thrower2.throwMemoryLimitException(new byte[2 * 1024 * 1024]); // 2MB (no limits)
+ }
+ catch(Ice.MemoryLimitException ex)
+ {
+ }
+ ThrowerPrx thrower3 = ThrowerPrxHelper.uncheckedCast(
+ communicator.stringToProxy("thrower:default -p 12012"));
+ try
+ {
+ thrower3.throwMemoryLimitException(new byte[1024]); // 1KB limit
+ test(false);
+ }
+ catch(Ice.ConnectionLostException ex)
+ {
+ }
+
out.println("ok");
}
diff --git a/java/test/src/main/java/test/Ice/exceptions/Server.java b/java/test/src/main/java/test/Ice/exceptions/Server.java
index 6ecdc901099..bb0140e0a5d 100644
--- a/java/test/src/main/java/test/Ice/exceptions/Server.java
+++ b/java/test/src/main/java/test/Ice/exceptions/Server.java
@@ -16,9 +16,15 @@ public class Server extends test.Util.Application
{
Ice.Communicator communicator = communicator();
Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
+ Ice.ObjectAdapter adapter2 = communicator.createObjectAdapter("TestAdapter2");
+ Ice.ObjectAdapter adapter3 = communicator.createObjectAdapter("TestAdapter3");
Ice.Object object = new ThrowerI();
adapter.add(object, communicator.stringToIdentity("thrower"));
+ adapter2.add(object, communicator.stringToIdentity("thrower"));
+ adapter3.add(object, communicator.stringToIdentity("thrower"));
adapter.activate();
+ adapter2.activate();
+ adapter3.activate();
return WAIT;
}
@@ -38,6 +44,10 @@ public class Server extends test.Util.Application
initData.properties.setProperty("Ice.Package.Test", "test.Ice.exceptions");
initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp");
initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max
+ initData.properties.setProperty("TestAdapter2.Endpoints", "default -p 12011");
+ initData.properties.setProperty("TestAdapter2.MessageSizeMax", "0");
+ initData.properties.setProperty("TestAdapter3.Endpoints", "default -p 12012");
+ initData.properties.setProperty("TestAdapter3.MessageSizeMax", "1");
return initData;
}
diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js
index 0a44caa195a..e98c9d2c4c6 100644
--- a/js/src/Ice/ConnectionI.js
+++ b/js/src/Ice/ConnectionI.js
@@ -99,6 +99,7 @@ var ConnectionI = Class({
this._warnUdp = instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0;
this._acmLastActivity = this._monitor !== null && this._monitor.getACM().timeout > 0 ? Date.now() : -1;
this._nextRequestId = 1;
+ this._messageSizeMax = adapter ? adapter.messageSizeMax() : instance.messageSizeMax();
this._batchAutoFlushSize = instance.batchAutoFlushSize();
this._batchStream = new BasicStream(instance, Protocol.currentProtocolEncoding);
this._batchStreamInUse = false;
@@ -990,9 +991,9 @@ var ConnectionI = Class({
{
throw new Ice.IllegalMessageSizeException();
}
- if(size > this._instance.messageSizeMax())
+ if(size > this._messageSizeMax)
{
- ExUtil.throwMemoryLimitException(size, this._instance.messageSizeMax());
+ ExUtil.throwMemoryLimitException(size, this._messageSizeMax);
}
if(size > this._readStream.size)
{
diff --git a/js/src/Ice/Instance.js b/js/src/Ice/Instance.js
index 38587bb2b2d..91cd701b469 100644
--- a/js/src/Ice/Instance.js
+++ b/js/src/Ice/Instance.js
@@ -325,11 +325,7 @@ var Instance = Ice.Class({
var defMessageSizeMax = 1024;
var num = this._initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defMessageSizeMax);
- if(num < 1)
- {
- this._messageSizeMax = defMessageSizeMax * 1024; // Ignore non-sensical values.
- }
- else if(num > 0x7fffffff / 1024)
+ if(num < 1 || num > 0x7fffffff / 1024)
{
this._messageSizeMax = 0x7fffffff;
}
diff --git a/js/src/Ice/ObjectAdapterI.js b/js/src/Ice/ObjectAdapterI.js
index ec069e75fa8..a65e3f30ece 100644
--- a/js/src/Ice/ObjectAdapterI.js
+++ b/js/src/Ice/ObjectAdapterI.js
@@ -44,6 +44,7 @@ var _suffixes =
"Locator.PreferSecure",
"Locator.CollocationOptimized",
"Locator.Router",
+ "MessageSizeMax",
"PublishedEndpoints",
"RegisterProcess",
"ReplicaGroupId",
@@ -97,6 +98,7 @@ var ObjectAdapterI = Ice.Class({
if(this._noConfig)
{
this._reference = this._instance.referenceFactory().createFromString("dummy -t", "");
+ this._messageSizeMax = this._instance.messageSizeMax();
promise.succeed(this, promise);
return;
}
@@ -151,6 +153,19 @@ var ObjectAdapterI = Ice.Class({
}
}
+ {
+ var defaultMessageSizeMax = this._instance.messageSizeMax() / 1024;
+ var num = properties.getPropertyAsIntWithDefault(this._name + ".MessageSizeMax", defaultMessageSizeMax);
+ if(num < 1 || num > 0x7fffffff / 1024)
+ {
+ this._messageSizeMax = 0x7fffffff;
+ }
+ else
+ {
+ this._messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes
+ }
+ }
+
try
{
@@ -461,6 +476,10 @@ var ObjectAdapterI = Ice.Class({
//
return this._servantManager;
},
+ messageSizeMax: function()
+ {
+ return this._messageSizeMax;
+ },
newProxy: function(ident, facet)
{
var endpoints = [];
diff --git a/js/test/Ice/exceptions/Client.js b/js/test/Ice/exceptions/Client.js
index ebfd35e6549..1c236aceba5 100644
--- a/js/test/Ice/exceptions/Client.js
+++ b/js/test/Ice/exceptions/Client.js
@@ -125,7 +125,6 @@
failCB,
function(ex)
{
- out.writeLine(ex);
test(ex instanceof Ice.ConnectionLostException);
out.writeLine("ok");
}
diff --git a/php/test/Ice/exceptions/Client.php b/php/test/Ice/exceptions/Client.php
index 05efe373a90..4bf8f798e16 100644
--- a/php/test/Ice/exceptions/Client.php
+++ b/php/test/Ice/exceptions/Client.php
@@ -281,7 +281,7 @@ function allTests($communicator)
}
catch(Exception $ex)
{
- $uue = $NS ? "Ice\\UnknownLocalException" : "Ice_UnknownLocalException";
+ $uue = $NS ? "Ice\\MemoryLimitException" : "Ice_MemoryLimitException";
if(!($ex instanceof $uue))
{
throw $ex;
@@ -295,7 +295,7 @@ function allTests($communicator)
}
catch(Exception $ex)
{
- $uue = $NS ? "Ice\\MemoryLimitException" : "Ice_MemoryLimitException";
+ $uue = $NS ? "Ice\\ConnectionLostException" : "Ice_ConnectionLostException";
if(!($ex instanceof $uue))
{
throw $ex;
diff --git a/php/test/Ice/exceptions/run.py b/php/test/Ice/exceptions/run.py
index 1da101f4919..144375fd2eb 100755
--- a/php/test/Ice/exceptions/run.py
+++ b/php/test/Ice/exceptions/run.py
@@ -21,25 +21,25 @@ sys.path.append(os.path.join(path[0], "scripts"))
import TestUtil
print("Running test with compact (default) format.")
-TestUtil.clientServerTest()
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Warn.Connections=0")
print("Running test with sliced format.")
-TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.SlicedFormat",
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.SlicedFormat --Ice.Warn.Connections=0",
additionalServerOptions="--Ice.Default.SlicedFormat")
print("Running test with 1.0 encoding.")
-TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.EncodingVersion=1.0",
+TestUtil.clientServerTest(additionalClientOptions="--Ice.Default.EncodingVersion=1.0 --Ice.Warn.Connections=0",
additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
print("Running test with compact (default) format and AMD server.")
-TestUtil.clientServerTest(server="serveramd")
+TestUtil.clientServerTest(server="serveramd", additionalClientOptions="--Ice.Warn.Connections=0")
print("Running test with sliced format and AMD server.")
TestUtil.clientServerTest(server="serveramd",
- additionalClientOptions="--Ice.Default.SlicedFormat",
+ additionalClientOptions="--Ice.Default.SlicedFormat --Ice.Warn.Connections=0",
additionalServerOptions="--Ice.Default.SlicedFormat")
print("Running test with 1.0 encoding and AMD server.")
TestUtil.clientServerTest(server="serveramd",
- additionalClientOptions="--Ice.Default.EncodingVersion=1.0",
+ additionalClientOptions="--Ice.Default.EncodingVersion=1.0 --Ice.Warn.Connections=0",
additionalServerOptions="--Ice.Default.EncodingVersion=1.0")
diff --git a/py/test/Ice/exceptions/AllTests.py b/py/test/Ice/exceptions/AllTests.py
index e49b2dfcc9c..1baaa87751c 100644
--- a/py/test/Ice/exceptions/AllTests.py
+++ b/py/test/Ice/exceptions/AllTests.py
@@ -473,13 +473,14 @@ def allTests(communicator):
print("ok")
+ if thrower.ice_getConnection():
sys.stdout.write("testing memory limit marshal exception...");
sys.stdout.flush();
try:
thrower.throwMemoryLimitException(array.array('B'));
test(False)
- except Ice.UnknownLocalException:
+ except Ice.MemoryLimitException:
pass
except:
print(sys.exc_info())
@@ -488,21 +489,12 @@ def allTests(communicator):
try:
thrower.throwMemoryLimitException(bytearray(20 * 1024)) # 20KB
test(False)
- except Ice.MemoryLimitException:
- pass
- except:
- test(False)
-
- try:
- thrower.end_throwMemoryLimitException(thrower.begin_throwMemoryLimitException(bytearray(20 * 1024))) # 20KB
- test(False)
- except Ice.MemoryLimitException:
+ except Ice.ConnectionLostException:
pass
except:
test(False)
- print("ok");
-
+ print("ok");
sys.stdout.write("catching object not exist exception... ")
sys.stdout.flush()
diff --git a/py/test/Ice/exceptions/Client.py b/py/test/Ice/exceptions/Client.py
index e81016e8f2f..6767e0ddf1d 100755
--- a/py/test/Ice/exceptions/Client.py
+++ b/py/test/Ice/exceptions/Client.py
@@ -28,6 +28,7 @@ try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
initData.properties.setProperty("Ice.MessageSizeMax", "10")
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
communicator = Ice.initialize(sys.argv, initData)
status = run(sys.argv, communicator)
except:
diff --git a/py/test/Ice/exceptions/Server.py b/py/test/Ice/exceptions/Server.py
index d1cae6efbe3..a522473ce01 100755
--- a/py/test/Ice/exceptions/Server.py
+++ b/py/test/Ice/exceptions/Server.py
@@ -21,9 +21,15 @@ import Test, TestI
def run(args, communicator):
adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter2 = communicator.createObjectAdapter("TestAdapter2")
+ adapter3 = communicator.createObjectAdapter("TestAdapter3")
object = TestI.ThrowerI()
adapter.add(object, communicator.stringToIdentity("thrower"))
+ adapter2.add(object, communicator.stringToIdentity("thrower"))
+ adapter3.add(object, communicator.stringToIdentity("thrower"))
adapter.activate()
+ adapter2.activate()
+ adapter3.activate()
communicator.waitForShutdown()
return True
@@ -31,8 +37,13 @@ try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
initData.properties.setProperty("Ice.Warn.Dispatch", "0")
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
initData.properties.setProperty("Ice.MessageSizeMax", "10")
+ initData.properties.setProperty("TestAdapter2.Endpoints", "default -p 12011")
+ initData.properties.setProperty("TestAdapter2.MessageSizeMax", "0")
+ initData.properties.setProperty("TestAdapter3.Endpoints", "default -p 12012")
+ initData.properties.setProperty("TestAdapter3.MessageSizeMax", "1")
communicator = Ice.initialize(sys.argv, initData)
status = run(sys.argv, communicator)
except:
diff --git a/py/test/Ice/exceptions/ServerAMD.py b/py/test/Ice/exceptions/ServerAMD.py
index 9dcb283e52b..f1e7562374a 100755
--- a/py/test/Ice/exceptions/ServerAMD.py
+++ b/py/test/Ice/exceptions/ServerAMD.py
@@ -141,9 +141,15 @@ class ThrowerI(Test.Thrower):
def run(args, communicator):
adapter = communicator.createObjectAdapter("TestAdapter")
+ adapter2 = communicator.createObjectAdapter("TestAdapter2")
+ adapter3 = communicator.createObjectAdapter("TestAdapter3")
object = ThrowerI()
adapter.add(object, communicator.stringToIdentity("thrower"))
+ adapter2.add(object, communicator.stringToIdentity("thrower"))
+ adapter3.add(object, communicator.stringToIdentity("thrower"))
adapter.activate()
+ adapter2.activate()
+ adapter3.activate()
communicator.waitForShutdown()
return True
@@ -151,8 +157,13 @@ try:
initData = Ice.InitializationData()
initData.properties = Ice.createProperties(sys.argv)
initData.properties.setProperty("Ice.Warn.Dispatch", "0")
+ initData.properties.setProperty("Ice.Warn.Connections", "0");
initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp")
initData.properties.setProperty("Ice.MessageSizeMax", "10")
+ initData.properties.setProperty("TestAdapter2.Endpoints", "default -p 12011")
+ initData.properties.setProperty("TestAdapter2.MessageSizeMax", "0")
+ initData.properties.setProperty("TestAdapter3.Endpoints", "default -p 12012")
+ initData.properties.setProperty("TestAdapter3.MessageSizeMax", "1")
communicator = Ice.initialize(sys.argv, initData)
status = run(sys.argv, communicator)
except:
diff --git a/rb/test/Ice/exceptions/AllTests.rb b/rb/test/Ice/exceptions/AllTests.rb
index 71f37469077..09100e6e5ee 100644
--- a/rb/test/Ice/exceptions/AllTests.rb
+++ b/rb/test/Ice/exceptions/AllTests.rb
@@ -270,7 +270,7 @@ def allTests(communicator)
begin
thrower.throwMemoryLimitException(Array.new(1, 0x00));
test(false)
- rescue Ice::UnknownLocalException
+ rescue Ice::MemoryLimitException
# Expected
rescue
test(false)
@@ -279,7 +279,7 @@ def allTests(communicator)
begin
thrower.throwMemoryLimitException(Array.new(20 * 1024, 0x00)) # 20KB
test(false)
- rescue Ice::MemoryLimitException
+ rescue Ice::ConnectionLostException
# Expected
rescue
print $!.backtrace.join("\n")
diff --git a/rb/test/Ice/exceptions/Client.rb b/rb/test/Ice/exceptions/Client.rb
index 00bd19a33f7..7a3203b7675 100755
--- a/rb/test/Ice/exceptions/Client.rb
+++ b/rb/test/Ice/exceptions/Client.rb
@@ -25,6 +25,7 @@ begin
initData = Ice::InitializationData.new
initData.properties = Ice.createProperties(ARGV)
initData.properties.setProperty("Ice.MessageSizeMax", "10")
+ initData.properties.setProperty("Ice.Warn.Connections", "0")
communicator = Ice.initialize(ARGV, initData)
status = run(ARGV, communicator)
rescue => ex
diff --git a/slice/Ice/LocalException.ice b/slice/Ice/LocalException.ice
index 6665d71d6ad..d2406bee2bb 100644
--- a/slice/Ice/LocalException.ice
+++ b/slice/Ice/LocalException.ice
@@ -920,7 +920,9 @@ local exception UnexpectedObjectException extends MarshalException
/**
*
- * This exception is raised if a request size exceeds the limit specified by the <tt>Ice.MessageSizeMax</tt> property.
+ * This exception is raised when Ice receives a request or reply
+ * message whose size exceeds the limit specified by the
+ * <tt>Ice.MessageSizeMax</tt> property.
*
**/
["cpp:ice_print"]
@@ -930,9 +932,8 @@ local exception MemoryLimitException extends MarshalException
/**
*
- * This exception is
- * raised when a string conversion to or from UTF-8 fails during
- * marshaling or unmarshaling.
+ * This exception is raised when a string conversion to or from UTF-8
+ * fails during marshaling or unmarshaling.
*
**/
["cpp:ice_print"]