diff options
author | Benoit Foucher <benoit@zeroc.com> | 2013-07-04 11:20:07 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2013-07-04 11:20:07 +0200 |
commit | 0df052034b03907de02d8eac162e84e5ba50bfd5 (patch) | |
tree | f424142a198431b2a8981bfaebe79410ef4f5481 | |
parent | Fixed ICE-5340 - FileLock jlint errors in android (diff) | |
download | ice-0df052034b03907de02d8eac162e84e5ba50bfd5.tar.bz2 ice-0df052034b03907de02d8eac162e84e5ba50bfd5.tar.xz ice-0df052034b03907de02d8eac162e84e5ba50bfd5.zip |
Fixed ICE-5369 - fixed asserting on AMD response if memory limit exception was raised
42 files changed, 418 insertions, 46 deletions
@@ -50,9 +50,19 @@ C++ Changes asynchronous invocations. +Java Changes +============ + +- Fixed an assertion which would occur if the marshalling of the + response of AMD callback raised a memory limit exception. + + C# Changes ========== +- Fixed an assertion which would occur if the marshalling of the + response of AMD callback raised a memory limit exception. + - Fixed a bug in slice2cs that caused incorrect code to be generated for a Slice structure that declares default values for its members. diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 60164571d5e..31ebf05c673 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -6619,7 +6619,8 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) _out << eb; _out << nl << "catch(Ice.LocalException ex__)"; _out << sb; - _out << nl << "ice_exception(ex__);"; + _out << nl << "exception__(ex__);"; + _out << nl << "return;"; _out << eb; } else diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 88630bc79b5..fa2f0781a0e 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -6877,7 +6877,8 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) out << eb; out << nl << "catch(Ice.LocalException __ex)"; out << sb; - out << nl << "ice_exception(__ex);"; + out << nl << "__exception(__ex);"; + out << nl << "return;"; out << eb; } else diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp index 8834c89ecad..caf331f30ff 100644 --- a/cpp/test/Ice/exceptions/AllTests.cpp +++ b/cpp/test/Ice/exceptions/AllTests.cpp @@ -1343,6 +1343,53 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) cout << "ok" << endl; } + { + cout << "testing memory limit marshal exception..." << flush; + try + { + thrower->throwMemoryLimitException(Ice::ByteSeq()); + test(collocated); + } + catch(const Ice::UnknownLocalException&) + { + } + catch(...) + { + test(false); + } + + try + { + thrower->throwMemoryLimitException(Ice::ByteSeq(20 * 1024)); // 20KB + test(collocated); + } + catch(const Ice::MemoryLimitException& ex) + { + } + catch(...) + { + test(false); + } + + if(!collocated) + { + try + { + thrower->end_throwMemoryLimitException( + thrower->begin_throwMemoryLimitException(Ice::ByteSeq(20 * 1024))); // 20KB + test(false); + } + catch(const Ice::MemoryLimitException&) + { + } + catch(...) + { + test(false); + } + } + cout << "ok" << endl; + } + cout << "catching object not exist exception... " << flush; Ice::Identity id = communicator->stringToIdentity("does not exist"); diff --git a/cpp/test/Ice/exceptions/Client.cpp b/cpp/test/Ice/exceptions/Client.cpp index f7e933a4dca..2fbacc09b8f 100644 --- a/cpp/test/Ice/exceptions/Client.cpp +++ b/cpp/test/Ice/exceptions/Client.cpp @@ -33,7 +33,10 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(); + initData.properties->setProperty("Ice.MessageSizeMax", "10"); // 10KB max + communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) diff --git a/cpp/test/Ice/exceptions/Server.cpp b/cpp/test/Ice/exceptions/Server.cpp index 629eacaeae8..61be1c3e69c 100644 --- a/cpp/test/Ice/exceptions/Server.cpp +++ b/cpp/test/Ice/exceptions/Server.cpp @@ -18,9 +18,6 @@ using namespace std; int run(int, char**, const Ice::CommunicatorPtr& communicator) { - Ice::PropertiesPtr properties = communicator->getProperties(); - properties->setProperty("Ice.Warn.Dispatch", "0"); - communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectPtr object = new ThrowerI(); adapter->add(object, communicator->stringToIdentity("thrower")); @@ -38,7 +35,12 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(); + initData.properties->setProperty("Ice.Warn.Dispatch", "0"); + initData.properties->setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); + initData.properties->setProperty("Ice.MessageSizeMax", "10"); // 10KB max + communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) diff --git a/cpp/test/Ice/exceptions/ServerAMD.cpp b/cpp/test/Ice/exceptions/ServerAMD.cpp index d859d9f43f2..8ff4d67d825 100644 --- a/cpp/test/Ice/exceptions/ServerAMD.cpp +++ b/cpp/test/Ice/exceptions/ServerAMD.cpp @@ -18,9 +18,6 @@ using namespace std; int run(int, char**, const Ice::CommunicatorPtr& communicator) { - Ice::PropertiesPtr properties = communicator->getProperties(); - properties->setProperty("Ice.Warn.Dispatch", "0"); - communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectPtr object = new ThrowerI(); adapter->add(object, communicator->stringToIdentity("thrower")); @@ -38,7 +35,12 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(); + initData.properties->setProperty("Ice.Warn.Dispatch", "0"); + initData.properties->setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); + initData.properties->setProperty("Ice.MessageSizeMax", "10"); // 10KB max + communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) diff --git a/cpp/test/Ice/exceptions/Test.ice b/cpp/test/Ice/exceptions/Test.ice index 9ef2874491a..a4952489338 100644 --- a/cpp/test/Ice/exceptions/Test.ice +++ b/cpp/test/Ice/exceptions/Test.ice @@ -9,6 +9,8 @@ #pragma once +#include <Ice/BuiltinSequences.ice> + module Test { @@ -90,6 +92,7 @@ module Mod void throwLocalException(); void throwNonIceException(); void throwAssertException(); + Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq); idempotent void throwLocalExceptionIdempotent(); diff --git a/cpp/test/Ice/exceptions/TestAMD.ice b/cpp/test/Ice/exceptions/TestAMD.ice index 25928f2076d..54052291e0f 100644 --- a/cpp/test/Ice/exceptions/TestAMD.ice +++ b/cpp/test/Ice/exceptions/TestAMD.ice @@ -9,6 +9,8 @@ #pragma once +#include <Ice/BuiltinSequences.ice> + module Test { @@ -91,6 +93,7 @@ module Mod void throwLocalException(); void throwNonIceException(); void throwAssertException(); + Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq); idempotent void throwLocalExceptionIdempotent(); diff --git a/cpp/test/Ice/exceptions/TestAMDI.cpp b/cpp/test/Ice/exceptions/TestAMDI.cpp index 8e37e9061f6..67786170906 100644 --- a/cpp/test/Ice/exceptions/TestAMDI.cpp +++ b/cpp/test/Ice/exceptions/TestAMDI.cpp @@ -196,6 +196,14 @@ ThrowerI::throwAssertException_async(const AMD_Thrower_throwAssertExceptionPtr&, } void +ThrowerI::throwMemoryLimitException_async(const AMD_Thrower_throwMemoryLimitExceptionPtr& cb, + const Ice::ByteSeq&, const Ice::Current&) +{ + cb->ice_response(Ice::ByteSeq(1024 * 20)); // 20 KB. +} + + +void ThrowerI::throwLocalExceptionIdempotent_async(const AMD_Thrower_throwLocalExceptionIdempotentPtr& cb, const Ice::Current&) { diff --git a/cpp/test/Ice/exceptions/TestAMDI.h b/cpp/test/Ice/exceptions/TestAMDI.h index be183a000f5..c03de42ed93 100644 --- a/cpp/test/Ice/exceptions/TestAMDI.h +++ b/cpp/test/Ice/exceptions/TestAMDI.h @@ -58,6 +58,8 @@ public: const Ice::Current&); virtual void throwAssertException_async(const Test::AMD_Thrower_throwAssertExceptionPtr&, const Ice::Current&); + virtual void throwMemoryLimitException_async(const Test::AMD_Thrower_throwMemoryLimitExceptionPtr&, + const Ice::ByteSeq&, const Ice::Current&); virtual void throwLocalExceptionIdempotent_async(const Test::AMD_Thrower_throwLocalExceptionIdempotentPtr&, const Ice::Current&); diff --git a/cpp/test/Ice/exceptions/TestI.cpp b/cpp/test/Ice/exceptions/TestI.cpp index 4ffbece9a6d..d6cd178c0d6 100644 --- a/cpp/test/Ice/exceptions/TestI.cpp +++ b/cpp/test/Ice/exceptions/TestI.cpp @@ -152,6 +152,12 @@ ThrowerI::throwAssertException(const Ice::Current&) assert(false); // Not supported in C++. } +Ice::ByteSeq +ThrowerI::throwMemoryLimitException(const Ice::ByteSeq&, const Ice::Current&) +{ + return Ice::ByteSeq(1024 * 20); // 20 KB. +} + void ThrowerI::throwLocalExceptionIdempotent(const Ice::Current&) { diff --git a/cpp/test/Ice/exceptions/TestI.h b/cpp/test/Ice/exceptions/TestI.h index 8c000801d9c..9417e84b9c5 100644 --- a/cpp/test/Ice/exceptions/TestI.h +++ b/cpp/test/Ice/exceptions/TestI.h @@ -40,6 +40,7 @@ public: virtual void throwLocalException(const Ice::Current&); virtual void throwNonIceException(const Ice::Current&); virtual void throwAssertException(const Ice::Current&); + virtual Ice::ByteSeq throwMemoryLimitException(const Ice::ByteSeq&, const Ice::Current&); virtual void throwLocalExceptionIdempotent(const Ice::Current&); diff --git a/cs/test/Ice/exceptions/AllTests.cs b/cs/test/Ice/exceptions/AllTests.cs index 6cefe09923f..af151dd0282 100644 --- a/cs/test/Ice/exceptions/AllTests.cs +++ b/cs/test/Ice/exceptions/AllTests.cs @@ -1308,6 +1308,54 @@ public class AllTests : TestCommon.TestApp WriteLine("ok"); } + Write("testing memory limit marshal exception..."); + Flush(); + { + try + { + thrower.throwMemoryLimitException(null); + test(collocated); + } + catch(Ice.UnknownLocalException) + { + } + catch(Exception) + { + test(false); + } + + try + { + thrower.throwMemoryLimitException(new byte[20 * 1024]); // 20KB + test(collocated); + } + catch(Ice.MemoryLimitException) + { + } + catch(Exception) + { + test(false); + } + + if(!collocated) + { + try + { + thrower.end_throwMemoryLimitException( + thrower.begin_throwMemoryLimitException(new byte[20 * 1024])); // 20KB + test(false); + } + catch(Ice.MemoryLimitException) + { + } + catch(Exception) + { + test(false); + } + } + } + WriteLine("ok"); + Write("catching object not exist exception... "); Flush(); diff --git a/cs/test/Ice/exceptions/Client.cs b/cs/test/Ice/exceptions/Client.cs index c1dd16ef3fa..c583f793ccb 100644 --- a/cs/test/Ice/exceptions/Client.cs +++ b/cs/test/Ice/exceptions/Client.cs @@ -34,16 +34,20 @@ public class Client try { - Ice.InitializationData data = new Ice.InitializationData(); + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(); #if COMPACT // // When using Ice for .NET Compact Framework, we need to specify // the assembly so that Ice can locate classes and exceptions. // - data.properties = Ice.Util.createProperties(); - data.properties.setProperty("Ice.FactoryAssemblies", "client"); + initData.properties.setProperty("Ice.FactoryAssemblies", "client"); #endif - communicator = Ice.Util.initialize(ref args, data); + // We don't need to disable warnings because we have a dummy logger. + //initData.properties.setProperty("Ice.Warn.Dispatch", "0"); + initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); + initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max + communicator = Ice.Util.initialize(ref args, initData); status = run(args, communicator); } catch(System.Exception ex) diff --git a/cs/test/Ice/exceptions/Makefile b/cs/test/Ice/exceptions/Makefile index 85561ac189f..3dc81fc27b6 100644 --- a/cs/test/Ice/exceptions/Makefile +++ b/cs/test/Ice/exceptions/Makefile @@ -28,7 +28,7 @@ include $(top_srcdir)/config/Make.rules.cs MCSFLAGS := $(MCSFLAGS) -target:exe -SLICE2CSFLAGS := $(SLICE2CSFLAGS) -I. +SLICE2CSFLAGS := $(SLICE2CSFLAGS) -I. -I$(slicedir) client.exe: $(C_SRCS) $(GEN_SRCS) $(MCS) $(MCSFLAGS) -out:$@ $(call ref,Ice) $(subst /,$(DSEP),$^) diff --git a/cs/test/Ice/exceptions/Server.cs b/cs/test/Ice/exceptions/Server.cs index 0f2153c2dce..1c8862594da 100644 --- a/cs/test/Ice/exceptions/Server.cs +++ b/cs/test/Ice/exceptions/Server.cs @@ -45,10 +45,6 @@ public class Server { private static int run(string[] args, Ice.Communicator communicator) { - Ice.Properties properties = communicator.getProperties(); - // We don't need to disable warnings because we have a dummy logger. - //properties.setProperty("Ice.Warn.Dispatch", "0"); - properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); Ice.Object @object = new ThrowerI(); adapter.add(@object, communicator.stringToIdentity("thrower")); @@ -64,12 +60,11 @@ public class Server try { - // - // For this test, we need a dummy logger, otherwise the - // assertion test will print an error message. - // Ice.InitializationData initData = new Ice.InitializationData(); - initData.logger = new DummyLogger(); + initData.properties = Ice.Util.createProperties(); + initData.properties.setProperty("Ice.Warn.Dispatch", "0"); + initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); + initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max communicator = Ice.Util.initialize(ref args, initData); status = run(args, communicator); } diff --git a/cs/test/Ice/exceptions/Test.ice b/cs/test/Ice/exceptions/Test.ice index 7ed53911ccd..afc46e2d68c 100644 --- a/cs/test/Ice/exceptions/Test.ice +++ b/cs/test/Ice/exceptions/Test.ice @@ -9,6 +9,8 @@ #pragma once +#include <Ice/BuiltinSequences.ice> + module Test { @@ -57,6 +59,7 @@ exception D void throwLocalException(); void throwNonIceException(); void throwAssertException(); + Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq); idempotent void throwLocalExceptionIdempotent(); diff --git a/cs/test/Ice/exceptions/TestAMD.ice b/cs/test/Ice/exceptions/TestAMD.ice index 0c50fd310fc..dbc194c50ac 100644 --- a/cs/test/Ice/exceptions/TestAMD.ice +++ b/cs/test/Ice/exceptions/TestAMD.ice @@ -9,6 +9,8 @@ #pragma once +#include <Ice/BuiltinSequences.ice> + module Test { @@ -57,6 +59,7 @@ exception D void throwLocalException(); void throwNonIceException(); void throwAssertException(); + Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq); idempotent void throwLocalExceptionIdempotent(); diff --git a/cs/test/Ice/exceptions/ThrowerAMDI.cs b/cs/test/Ice/exceptions/ThrowerAMDI.cs index 86bb98cd185..804b6fc368f 100644 --- a/cs/test/Ice/exceptions/ThrowerAMDI.cs +++ b/cs/test/Ice/exceptions/ThrowerAMDI.cs @@ -139,6 +139,12 @@ public class ThrowerI : ThrowerDisp_ Debug.Assert(false); } + public override void throwMemoryLimitException_async(AMD_Thrower_throwMemoryLimitException cb, byte[] seq, + Ice.Current current) + { + cb.ice_response(new byte[1024 * 20]); // 20KB is over the configured 10KB message size max. + } + public override void throwLocalExceptionIdempotent_async(AMD_Thrower_throwLocalExceptionIdempotent e, Ice.Current current) { diff --git a/cs/test/Ice/exceptions/ThrowerI.cs b/cs/test/Ice/exceptions/ThrowerI.cs index 6fb352e28da..b3e01247cd0 100644 --- a/cs/test/Ice/exceptions/ThrowerI.cs +++ b/cs/test/Ice/exceptions/ThrowerI.cs @@ -101,6 +101,11 @@ public sealed class ThrowerI : ThrowerDisp_ { Debug.Assert(false); } + + public override byte[] throwMemoryLimitException(byte[] seq, Ice.Current current) + { + return new byte[1024 * 20]; // 20KB is over the configured 10KB message size max. + } public override void throwLocalExceptionIdempotent(Ice.Current current) { diff --git a/java/test/Ice/exceptions/AMDServer.java b/java/test/Ice/exceptions/AMDServer.java index 0e4aae17c71..86d47bd6e84 100644 --- a/java/test/Ice/exceptions/AMDServer.java +++ b/java/test/Ice/exceptions/AMDServer.java @@ -33,6 +33,7 @@ public class AMDServer extends test.Util.Application initData.properties = Ice.Util.createProperties(argsH); 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 // We don't need to disable warnings, because we have a dummy logger. // properties.setProperty("Ice.Warn.Dispatch", "0"); diff --git a/java/test/Ice/exceptions/AMDThrowerI.java b/java/test/Ice/exceptions/AMDThrowerI.java index bb69ac2a1da..9f924e42f56 100644 --- a/java/test/Ice/exceptions/AMDThrowerI.java +++ b/java/test/Ice/exceptions/AMDThrowerI.java @@ -16,6 +16,7 @@ import test.Ice.exceptions.AMD.Test.AMD_Thrower_supportsUndeclaredExceptions; import test.Ice.exceptions.AMD.Test.AMD_Thrower_throwAasA; import test.Ice.exceptions.AMD.Test.AMD_Thrower_throwAorDasAorD; import test.Ice.exceptions.AMD.Test.AMD_Thrower_throwAssertException; +import test.Ice.exceptions.AMD.Test.AMD_Thrower_throwMemoryLimitException; import test.Ice.exceptions.AMD.Test.AMD_Thrower_throwBasA; import test.Ice.exceptions.AMD.Test.AMD_Thrower_throwBasB; import test.Ice.exceptions.AMD.Test.AMD_Thrower_throwCasA; @@ -189,6 +190,12 @@ public final class AMDThrowerI extends _ThrowerDisp } public void + throwMemoryLimitException_async(AMD_Thrower_throwMemoryLimitException cb, byte[] seq, Ice.Current current) + { + cb.ice_response(new byte[1024 * 20]); // 20KB is over the configured 10KB message size max. + } + + public void throwLocalExceptionIdempotent_async(AMD_Thrower_throwLocalExceptionIdempotent cb, Ice.Current current) { cb.ice_exception(new Ice.TimeoutException()); diff --git a/java/test/Ice/exceptions/AllTests.java b/java/test/Ice/exceptions/AllTests.java index 88f6a4271fd..e45abf76b64 100644 --- a/java/test/Ice/exceptions/AllTests.java +++ b/java/test/Ice/exceptions/AllTests.java @@ -1739,6 +1739,57 @@ public class AllTests out.println("ok"); } + out.print("testing memory limit marshal exception..."); + out.flush(); + { + try + { + thrower.throwMemoryLimitException(null); + test(collocated); + } + catch(Ice.UnknownLocalException ex) + { + } + catch(Throwable ex) + { + ex.printStackTrace(); + test(false); + } + + try + { + thrower.throwMemoryLimitException(new byte[20 * 1024]); // 20KB + test(collocated); + } + catch(Ice.MemoryLimitException ex) + { + } + catch(Throwable ex) + { + ex.printStackTrace(); + test(false); + } + + if(!collocated) + { + try + { + thrower.end_throwMemoryLimitException( + thrower.begin_throwMemoryLimitException(new byte[20 * 1024])); // 20KB + test(false); + } + catch(Ice.MemoryLimitException ex) + { + } + catch(Throwable ex) + { + ex.printStackTrace(); + test(false); + } + } + } + out.println("ok"); + out.print("catching object not exist exception... "); out.flush(); diff --git a/java/test/Ice/exceptions/Client.java b/java/test/Ice/exceptions/Client.java index 51b6f072a81..e26144144a6 100644 --- a/java/test/Ice/exceptions/Client.java +++ b/java/test/Ice/exceptions/Client.java @@ -27,6 +27,7 @@ public class Client extends test.Util.Application initData.properties = Ice.Util.createProperties(argsH); initData.properties.setProperty("Ice.Package.Test", "test.Ice.exceptions"); initData.properties.setProperty("Ice.Warn.Connections", "0"); + initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max return initData; } diff --git a/java/test/Ice/exceptions/Server.java b/java/test/Ice/exceptions/Server.java index 97e4c3048b0..767526a7c36 100644 --- a/java/test/Ice/exceptions/Server.java +++ b/java/test/Ice/exceptions/Server.java @@ -29,6 +29,7 @@ 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 // We don't need to disable warnings, because we have a dummy logger. // properties.setProperty("Ice.Warn.Dispatch", "0"); diff --git a/java/test/Ice/exceptions/Test.ice b/java/test/Ice/exceptions/Test.ice index 2731dd1ec79..9df91f3013f 100644 --- a/java/test/Ice/exceptions/Test.ice +++ b/java/test/Ice/exceptions/Test.ice @@ -9,6 +9,8 @@ #pragma once +#include <Ice/BuiltinSequences.ice> + [["java:package:test.Ice.exceptions"]] module Test { @@ -59,6 +61,7 @@ exception D void throwLocalException(); void throwNonIceException(); void throwAssertException(); + Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq); idempotent void throwLocalExceptionIdempotent(); diff --git a/java/test/Ice/exceptions/TestAMD.ice b/java/test/Ice/exceptions/TestAMD.ice index 830815c621c..a9b8b7be0a2 100644 --- a/java/test/Ice/exceptions/TestAMD.ice +++ b/java/test/Ice/exceptions/TestAMD.ice @@ -9,6 +9,8 @@ #pragma once +#include <Ice/BuiltinSequences.ice> + [["java:package:test.Ice.exceptions.AMD"]] module Test { @@ -54,6 +56,7 @@ exception D void throwLocalException(); void throwNonIceException(); void throwAssertException(); + Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq); idempotent void throwLocalExceptionIdempotent(); diff --git a/java/test/Ice/exceptions/ThrowerI.java b/java/test/Ice/exceptions/ThrowerI.java index 1d190443fd1..47441831694 100644 --- a/java/test/Ice/exceptions/ThrowerI.java +++ b/java/test/Ice/exceptions/ThrowerI.java @@ -155,6 +155,12 @@ public final class ThrowerI extends _ThrowerDisp throw new java.lang.AssertionError(); } + public byte[] + throwMemoryLimitException(byte[] seq, Ice.Current current) + { + return new byte[1024 * 20]; // 20KB is over the configured 10KB message size max. + } + public void throwAfterResponse(Ice.Current current) { diff --git a/php/test/Ice/exceptions/Client.php b/php/test/Ice/exceptions/Client.php index 401ffe95207..adf6b2ccdfb 100644 --- a/php/test/Ice/exceptions/Client.php +++ b/php/test/Ice/exceptions/Client.php @@ -271,6 +271,40 @@ function allTests($communicator) echo "ok\n"; } + { + echo "testing memory limit marshal exception..."; + flush(); + try + { + $thrower->throwMemoryLimitException(array(0x00)); + test(false); + } + catch(Exception $ex) + { + $uue = $NS ? "Ice\\UnknownLocalException" : "Ice_UnknownLocalException"; + if(!($ex instanceof $uue)) + { + throw $ex; + } + } + + try + { + $thrower->throwMemoryLimitException(array_pad(array(), 20 * 1024, 0x00)); + test(false); + } + catch(Exception $ex) + { + $uue = $NS ? "Ice\\MemoryLimitException" : "Ice_MemoryLimitException"; + if(!($ex instanceof $uue)) + { + throw $ex; + } + } + + echo "ok\n"; + } + echo "catching object not exist exception... "; flush(); @@ -393,7 +427,10 @@ function allTests($communicator) return $thrower; } -$communicator = Ice_initialize($argv); +$initData = new Ice_InitializationData; +$initData->properties = Ice_getProperties(); +$initData->properties->setProperty("Ice.MessageSizeMax", "10"); +$communicator = Ice_initialize($argv, $initData); $thrower = allTests($communicator); $thrower->shutdown(); $communicator->destroy(); diff --git a/php/test/Ice/exceptions/Test.ice b/php/test/Ice/exceptions/Test.ice index 93b72b57078..066ed4a9055 100644 --- a/php/test/Ice/exceptions/Test.ice +++ b/php/test/Ice/exceptions/Test.ice @@ -9,6 +9,8 @@ #pragma once +#include <Ice/BuiltinSequences.ice> + module Test { @@ -55,6 +57,7 @@ exception D void throwUndeclaredC(int a, int b, int c); void throwLocalException(); void throwNonIceException(); + Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq); idempotent void throwLocalExceptionIdempotent(); }; diff --git a/py/test/Ice/exceptions/AllTests.py b/py/test/Ice/exceptions/AllTests.py index 4cdd3915369..370bfd5edb1 100644 --- a/py/test/Ice/exceptions/AllTests.py +++ b/py/test/Ice/exceptions/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, threading, sys +import Ice, Test, threading, sys, array def test(b): if not b: @@ -688,6 +688,39 @@ def allTests(communicator): print("ok") + + sys.stdout.write("testing memory limit marshal exception..."); + sys.stdout.flush(); + + try: + thrower.throwMemoryLimitException(array.array('B')); + test(False) + except Ice.UnknownLocalException: + pass + except: + print(sys.exc_info()) + test(False) + + try: + thrower.throwMemoryLimitException(array.array('B', (0 for x in xrange(20 * 1024)))) # 20KB + test(False) + except Ice.MemoryLimitException: + pass + except: + test(False) + + try: + thrower.end_throwMemoryLimitException( + thrower.begin_throwMemoryLimitException(array.array('B', (0 for x in xrange(20 * 1024))))) # 20KB + test(False) + except Ice.MemoryLimitException: + pass + except: + test(False) + + 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 ebaec59fb75..5bdfcbcd715 100755 --- a/py/test/Ice/exceptions/Client.py +++ b/py/test/Ice/exceptions/Client.py @@ -11,7 +11,12 @@ import os, sys, traceback import Ice -Ice.loadSlice('Test.ice') +slice_dir = Ice.getSliceDir() +if not slice_dir: + print(sys.argv[0] + ': Slice directory not found.') + sys.exit(1) + +Ice.loadSlice('"-I' + slice_dir + '" Test.ice') import AllTests def run(args, communicator): @@ -20,7 +25,10 @@ def run(args, communicator): return True try: - communicator = Ice.initialize(sys.argv) + initData = Ice.InitializationData() + initData.properties = Ice.createProperties(sys.argv) + initData.properties.setProperty("Ice.MessageSizeMax", "10") + communicator = Ice.initialize(sys.argv, initData) status = run(sys.argv, communicator) except: traceback.print_exc() diff --git a/py/test/Ice/exceptions/Collocated.py b/py/test/Ice/exceptions/Collocated.py index 6ec38642450..6e40ee8b83f 100755 --- a/py/test/Ice/exceptions/Collocated.py +++ b/py/test/Ice/exceptions/Collocated.py @@ -11,7 +11,12 @@ import os, sys, traceback import Ice -Ice.loadSlice('Test.ice') +slice_dir = Ice.getSliceDir() +if not slice_dir: + print(sys.argv[0] + ': Slice directory not found.') + sys.exit(1) + +Ice.loadSlice('"-I' + slice_dir + '" Test.ice') import Test, TestI, AllTests def run(args, communicator): @@ -28,7 +33,10 @@ def run(args, communicator): return True try: - communicator = Ice.initialize(sys.argv) + initData = Ice.InitializationData() + initData.properties = Ice.createProperties(sys.argv) + initData.properties.setProperty("Ice.MessageSizeMax", "10") + communicator = Ice.initialize(sys.argv, initData) status = run(sys.argv, communicator) except: traceback.print_exc() diff --git a/py/test/Ice/exceptions/Server.py b/py/test/Ice/exceptions/Server.py index 11062e28eb9..215717c254a 100755 --- a/py/test/Ice/exceptions/Server.py +++ b/py/test/Ice/exceptions/Server.py @@ -11,13 +11,15 @@ import os, sys, traceback import Ice -Ice.loadSlice('Test.ice') +slice_dir = Ice.getSliceDir() +if not slice_dir: + print(sys.argv[0] + ': Slice directory not found.') + sys.exit(1) + +Ice.loadSlice('"-I' + slice_dir + '" Test.ice') import Test, TestI def run(args, communicator): - properties = communicator.getProperties() - properties.setProperty("Ice.Warn.Dispatch", "0") - properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp") adapter = communicator.createObjectAdapter("TestAdapter") object = TestI.ThrowerI() adapter.add(object, communicator.stringToIdentity("thrower")) @@ -26,7 +28,12 @@ def run(args, communicator): return True try: - communicator = Ice.initialize(sys.argv) + initData = Ice.InitializationData() + initData.properties = Ice.createProperties(sys.argv) + initData.properties.setProperty("Ice.Warn.Dispatch", "0") + initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp") + initData.properties.setProperty("Ice.MessageSizeMax", "10") + communicator = Ice.initialize(sys.argv, initData) status = run(sys.argv, communicator) except: traceback.print_exc() diff --git a/py/test/Ice/exceptions/ServerAMD.py b/py/test/Ice/exceptions/ServerAMD.py index b5eaaf3b10c..41b3fb3675e 100755 --- a/py/test/Ice/exceptions/ServerAMD.py +++ b/py/test/Ice/exceptions/ServerAMD.py @@ -8,10 +8,15 @@ # # ********************************************************************** -import os, sys, traceback +import os, sys, traceback, array import Ice -Ice.loadSlice('TestAMD.ice') +slice_dir = Ice.getSliceDir() +if not slice_dir: + print(sys.argv[0] + ': Slice directory not found.') + sys.exit(1) + +Ice.loadSlice('"-I' + slice_dir + '" TestAMD.ice') import Test class ThrowerI(Test.Thrower): @@ -109,6 +114,9 @@ class ThrowerI(Test.Thrower): def throwAssertException_async(self, cb, current=None): raise RuntimeError("operation `throwAssertException' not supported") + def throwMemoryLimitException_async(self, cb, seq, current=None): + cb.ice_response(array.array('B', (0 for x in xrange(20 * 1024)))) + def throwLocalExceptionIdempotent_async(self, cb, current=None): cb.ice_exception(Ice.TimeoutException()) @@ -121,9 +129,6 @@ class ThrowerI(Test.Thrower): raise RuntimeError("12345") def run(args, communicator): - properties = communicator.getProperties() - properties.setProperty("Ice.Warn.Dispatch", "0") - properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp") adapter = communicator.createObjectAdapter("TestAdapter") object = ThrowerI() adapter.add(object, communicator.stringToIdentity("thrower")) @@ -132,7 +137,12 @@ def run(args, communicator): return True try: - communicator = Ice.initialize(sys.argv) + initData = Ice.InitializationData() + initData.properties = Ice.createProperties(sys.argv) + initData.properties.setProperty("Ice.Warn.Dispatch", "0") + initData.properties.setProperty("TestAdapter.Endpoints", "default -p 12010:udp") + initData.properties.setProperty("Ice.MessageSizeMax", "10") + communicator = Ice.initialize(sys.argv, initData) status = run(sys.argv, communicator) except: traceback.print_exc() diff --git a/py/test/Ice/exceptions/Test.ice b/py/test/Ice/exceptions/Test.ice index 436c4ee369f..4f953cd173e 100644 --- a/py/test/Ice/exceptions/Test.ice +++ b/py/test/Ice/exceptions/Test.ice @@ -9,6 +9,8 @@ #pragma once +#include <Ice/BuiltinSequences.ice> + module Test { @@ -68,6 +70,7 @@ module Mod void throwLocalException(); void throwNonIceException(); void throwAssertException(); + Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq); idempotent void throwLocalExceptionIdempotent(); diff --git a/py/test/Ice/exceptions/TestAMD.ice b/py/test/Ice/exceptions/TestAMD.ice index 2b4d455f09f..0665844b713 100644 --- a/py/test/Ice/exceptions/TestAMD.ice +++ b/py/test/Ice/exceptions/TestAMD.ice @@ -9,6 +9,8 @@ #pragma once +#include <Ice/BuiltinSequences.ice> + module Test { @@ -65,6 +67,7 @@ module Mod void throwLocalException(); void throwNonIceException(); void throwAssertException(); + Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq); void throwAfterResponse(); void throwAfterException() throws A; diff --git a/py/test/Ice/exceptions/TestI.py b/py/test/Ice/exceptions/TestI.py index f1398a54258..64ed7f470fe 100644 --- a/py/test/Ice/exceptions/TestI.py +++ b/py/test/Ice/exceptions/TestI.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test +import Ice, Test, array class ThrowerI(Test.Thrower): def shutdown(self, current=None): @@ -89,6 +89,9 @@ class ThrowerI(Test.Thrower): def throwAssertException(self, current=None): raise RuntimeError("operation `throwAssertException' not supported") + def throwMemoryLimitException(self, seq, current=None): + return array.array('B', (0 for x in xrange(20 * 1024))) + def throwLocalExceptionIdempotent(self, current=None): raise Ice.TimeoutException() diff --git a/rb/test/Ice/exceptions/AllTests.rb b/rb/test/Ice/exceptions/AllTests.rb index 42799a338a5..42feb37e01a 100644 --- a/rb/test/Ice/exceptions/AllTests.rb +++ b/rb/test/Ice/exceptions/AllTests.rb @@ -264,6 +264,30 @@ def allTests(communicator) puts "ok" end + print "testing memory limit marshal exception..." + STDOUT.flush + + begin + thrower.throwMemoryLimitException(Array.new(1, 0x00)); + test(false) + rescue Ice::UnknownLocalException + # Expected + rescue + test(false) + end + + begin + thrower.throwMemoryLimitException(Array.new(20 * 1024, 0x00)) # 20KB + test(false) + rescue Ice::MemoryLimitException + # Expected + rescue + print $!.backtrace.join("\n") + test(false) + end + + puts "ok" + print "catching object not exist exception... " STDOUT.flush diff --git a/rb/test/Ice/exceptions/Client.rb b/rb/test/Ice/exceptions/Client.rb index eab71ed1f48..365a0eb4249 100755 --- a/rb/test/Ice/exceptions/Client.rb +++ b/rb/test/Ice/exceptions/Client.rb @@ -9,9 +9,10 @@ # ********************************************************************** require 'pathname' - require 'Ice' -Ice::loadSlice('Test.ice') + +slice_dir = Ice.getSliceDir +Ice::loadSlice("'-I" + slice_dir + "' Test.ice") require './AllTests' def run(args, communicator) @@ -21,7 +22,10 @@ def run(args, communicator) end begin - communicator = Ice.initialize(ARGV) + initData = Ice::InitializationData.new + initData.properties = Ice.createProperties(ARGV) + initData.properties.setProperty("Ice.MessageSizeMax", "10") + communicator = Ice.initialize(ARGV, initData) status = run(ARGV, communicator) rescue => ex puts $! diff --git a/rb/test/Ice/exceptions/Test.ice b/rb/test/Ice/exceptions/Test.ice index e7360eb725c..1f549f31ca5 100644 --- a/rb/test/Ice/exceptions/Test.ice +++ b/rb/test/Ice/exceptions/Test.ice @@ -9,6 +9,8 @@ #pragma once +#include <Ice/BuiltinSequences.ice> + module Test { @@ -69,6 +71,7 @@ module Mod void throwLocalException(); void throwNonIceException(); void throwAssertException(); + Ice::ByteSeq throwMemoryLimitException(Ice::ByteSeq seq); idempotent void throwLocalExceptionIdempotent(); }; |