diff options
author | Joe George <joe@zeroc.com> | 2020-07-07 16:57:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-07 16:57:51 -0400 |
commit | 6c0e7e6fcabde691e7c38a814b6171f9f4e77d09 (patch) | |
tree | aed41fdff6561e134c73da214e580be0910e6f6a /ruby | |
parent | Copy python dependencies to the extension directory - Close #926 (#927) (diff) | |
download | ice-6c0e7e6fcabde691e7c38a814b6171f9f4e77d09.tar.bz2 ice-6c0e7e6fcabde691e7c38a814b6171f9f4e77d09.tar.xz ice-6c0e7e6fcabde691e7c38a814b6171f9f4e77d09.zip |
Add class cycle detection during unmarshaling (#946)
Add support for detection of class cycles during unmarshaling in
languages which do no have garbage collection: C++, Swift, and Objective-C.
A `MarshalException` is thrown when a cycle is detected.
The property `Ice.AcceptClassCycles` can be set to a value greater than `0`
to change this behavior.
Diffstat (limited to 'ruby')
-rw-r--r-- | ruby/src/IceRuby/Communicator.cpp | 3 | ||||
-rw-r--r-- | ruby/test/Ice/objects/AllTests.rb | 14 | ||||
-rw-r--r-- | ruby/test/Ice/objects/Test.ice | 3 |
3 files changed, 20 insertions, 0 deletions
diff --git a/ruby/src/IceRuby/Communicator.cpp b/ruby/src/IceRuby/Communicator.cpp index 6050352e5d1..29f4f9e387e 100644 --- a/ruby/src/IceRuby/Communicator.cpp +++ b/ruby/src/IceRuby/Communicator.cpp @@ -207,6 +207,9 @@ IceRuby_initialize(int argc, VALUE* argv, VALUE /*self*/) data.properties = Ice::createProperties(seq, data.properties); } + // Always accept cycles in Ruby + data.properties->setProperty("Ice.AcceptClassCycles", "1"); + // // Remaining command line options are passed to the communicator // as an argument vector in case they contain plugin properties. diff --git a/ruby/test/Ice/objects/AllTests.rb b/ruby/test/Ice/objects/AllTests.rb index 65d1faa0fcf..1a01c9b5864 100644 --- a/ruby/test/Ice/objects/AllTests.rb +++ b/ruby/test/Ice/objects/AllTests.rb @@ -404,5 +404,19 @@ def allTests(helper, communicator) test(f32.f2.ice_getIdentity().name == "F22") end puts "ok" + + print "testing sending class cycle... " + STDOUT.flush + rec = Test::Recursive.new + rec.v = rec + acceptsCycles = initial.acceptsClassCycles() + begin + initial.setCycle(rec) + test(acceptsCycles) + rescue Ice::UnknownLocalException => ex + test(!acceptsCycles) + end + puts "ok" + return initial end diff --git a/ruby/test/Ice/objects/Test.ice b/ruby/test/Ice/objects/Test.ice index b4e0f3fd690..af4ab4786c9 100644 --- a/ruby/test/Ice/objects/Test.ice +++ b/ruby/test/Ice/objects/Test.ice @@ -186,6 +186,9 @@ class Initial void setRecursive(Recursive p); bool supportsClassGraphDepthMax(); + void setCycle(Recursive r); + bool acceptsClassCycles(); + ["marshaled-result"] B getMB(); ["amd", "marshaled-result"] B getAMDMB(); |