diff options
author | Mark Spruiell <mes@zeroc.com> | 2017-01-30 13:45:21 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2017-01-30 13:45:21 -0800 |
commit | 61270a10f980933cf582edb766f10c8ac6d86e8a (patch) | |
tree | 45ab4a7c2986954054fce613bc3c8f7967e7951e /java-compat | |
parent | Fix slice2cpp build failure (diff) | |
download | ice-61270a10f980933cf582edb766f10c8ac6d86e8a.tar.bz2 ice-61270a10f980933cf582edb766f10c8ac6d86e8a.tar.xz ice-61270a10f980933cf582edb766f10c8ac6d86e8a.zip |
merging IceBridge into master
Diffstat (limited to 'java-compat')
27 files changed, 525 insertions, 126 deletions
diff --git a/java-compat/src/Ice/src/main/java/Ice/Callback_Connection_heartbeat.java b/java-compat/src/Ice/src/main/java/Ice/Callback_Connection_heartbeat.java new file mode 100644 index 00000000000..e02ef2906c7 --- /dev/null +++ b/java-compat/src/Ice/src/main/java/Ice/Callback_Connection_heartbeat.java @@ -0,0 +1,55 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +package Ice; + +/** + * Asynchronous callback base class for Connection.begin_heartbeat. + **/ +public abstract class Callback_Connection_heartbeat extends IceInternal.CallbackBase +{ + /** + * Called when the invocation raises an Ice run-time exception. + * + * @param ex The Ice run-time exception raised by the operation. + **/ + public abstract void exception(LocalException ex); + + /** + * Called when a queued invocation is sent successfully. + **/ + public void sent(boolean sentSynchronously) + { + } + + @Override + public final void _iceCompleted(AsyncResult __result) + { + try + { + __result.getConnection().end_heartbeat(__result); + } + catch(LocalException __ex) + { + exception(__ex); + } + } + + @Override + public final void _iceSent(AsyncResult __result) + { + sent(__result.sentSynchronously()); + } + + @Override + public final boolean _iceHasSentCallback() + { + return true; + } +} diff --git a/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java b/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java index f4f1b32f4bf..84131a38cfc 100644 --- a/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java +++ b/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java @@ -155,25 +155,27 @@ public final class ConnectionI extends IceInternal.EventHandler } @Override - synchronized public void close(boolean force) + synchronized public void close(ConnectionClose mode) { if(Thread.interrupted()) { throw new Ice.OperationInterruptedException(); } - if(force) + if(mode == ConnectionClose.CloseForcefully) { - setState(StateClosed, new ForcedCloseConnectionException()); + setState(StateClosed, new ConnectionManuallyClosedException(false)); + } + else if(mode == ConnectionClose.CloseGracefully) + { + setState(StateClosing, new ConnectionManuallyClosedException(true)); } else { + assert(mode == ConnectionClose.CloseGracefullyAndWait); + // - // If we do a graceful shutdown, then we wait until all - // outstanding requests have been completed. Otherwise, - // the CloseConnectionException will cause all outstanding - // requests to be retried, regardless of whether the - // server has processed them or not. + // Wait until all outstanding requests have been completed. // while(!_asyncRequests.isEmpty()) { @@ -187,7 +189,7 @@ public final class ConnectionI extends IceInternal.EventHandler } } - setState(StateClosing, new CloseConnectionException()); + setState(StateClosing, new ConnectionManuallyClosedException(true)); } } @@ -279,14 +281,14 @@ public final class ConnectionI extends IceInternal.EventHandler // We send a heartbeat if there was no activity in the last // (timeout / 4) period. Sending a heartbeat sooner than // really needed is safer to ensure that the receiver will - // receive in time the heartbeat. Sending the heartbeat if + // receive the heartbeat in time. Sending the heartbeat if // there was no activity in the last (timeout / 2) period // isn't enough since monitor() is called only every (timeout // / 2) period. // // Note that this doesn't imply that we are sending 4 // heartbeats per timeout period because the monitor() method - // is sill only called every (timeout / 2) period. + // is still only called every (timeout / 2) period. // if(acm.heartbeat == ACMHeartbeat.HeartbeatAlways || (acm.heartbeat != ACMHeartbeat.HeartbeatOff && _writeStream.isEmpty() && @@ -518,6 +520,155 @@ public final class ConnectionI extends IceInternal.EventHandler } @Override + public void heartbeat() + { + end_heartbeat(begin_heartbeat()); + } + + private static final String __heartbeat_name = "heartbeat"; + + @Override + public AsyncResult begin_heartbeat() + { + return begin_heartbeatInternal(null); + } + + @Override + public AsyncResult begin_heartbeat(Callback cb) + { + return begin_heartbeatInternal(cb); + } + + @Override + public AsyncResult begin_heartbeat(Callback_Connection_heartbeat cb) + { + return begin_heartbeatInternal(cb); + } + + @Override + public AsyncResult begin_heartbeat(IceInternal.Functional_VoidCallback __responseCb, + final IceInternal.Functional_GenericCallback1<Ice.Exception> __exceptionCb, + IceInternal.Functional_BoolCallback __sentCb) + { + return begin_heartbeatInternal(new IceInternal.Functional_CallbackBase(false, __exceptionCb, __sentCb) + { + @Override + public final void _iceCompleted(AsyncResult __result) + { + try + { + __result.getConnection().end_heartbeat(__result); + } + catch(Exception __ex) + { + __exceptionCb.apply(__ex); + } + } + }); + } + + static class HeartbeatAsync extends IceInternal.OutgoingAsyncBase + { + public static HeartbeatAsync check(AsyncResult r, Connection con, String operation) + { + check(r, operation); + if(!(r instanceof HeartbeatAsync)) + { + throw new IllegalArgumentException("Incorrect AsyncResult object for end_" + operation + " method"); + } + if(r.getConnection() != con) + { + throw new IllegalArgumentException("Connection for call to end_" + operation + + " does not match connection that was used to call corresponding " + + "begin_" + operation + " method"); + } + return (HeartbeatAsync)r; + } + + public HeartbeatAsync(ConnectionI con, Communicator communicator, IceInternal.Instance instance, + String operation, IceInternal.CallbackBase callback) + { + super(communicator, instance, operation, callback); + _connection = con; + } + + @Override + public Connection getConnection() + { + return _connection; + } + + public void invoke() + { + try + { + _os.writeBlob(IceInternal.Protocol.magic); + ProtocolVersion.ice_write(_os, IceInternal.Protocol.currentProtocol); + EncodingVersion.ice_write(_os, IceInternal.Protocol.currentProtocolEncoding); + _os.writeByte(IceInternal.Protocol.validateConnectionMsg); + _os.writeByte((byte) 0); + _os.writeInt(IceInternal.Protocol.headerSize); // Message size. + + int status; + if(_instance.queueRequests()) + { + status = _instance.getQueueExecutor().execute(new Callable<Integer>() + { + @Override + public Integer call() throws IceInternal.RetryException + { + return _connection.sendAsyncRequest(HeartbeatAsync.this, false, false, 0); + } + }); + } + else + { + status = _connection.sendAsyncRequest(this, false, false, 0); + } + + if((status & IceInternal.AsyncStatus.Sent) > 0) + { + _sentSynchronously = true; + if((status & IceInternal.AsyncStatus.InvokeSentCallback) > 0) + { + invokeSent(); + } + } + } + catch(IceInternal.RetryException ex) + { + if(completed(ex.get())) + { + invokeCompletedAsync(); + } + } + catch(Ice.Exception ex) + { + if(completed(ex)) + { + invokeCompletedAsync(); + } + } + } + + private Ice.ConnectionI _connection; + } + + private AsyncResult begin_heartbeatInternal(IceInternal.CallbackBase cb) + { + HeartbeatAsync result = new HeartbeatAsync(this, _communicator, _instance, __heartbeat_name, cb); + result.invoke(); + return result; + } + + @Override + public void end_heartbeat(AsyncResult ir) + { + HeartbeatAsync r = HeartbeatAsync.check(ir, this, __heartbeat_name); + r.waitForResponseOrUserEx(); + } + + @Override synchronized public void setACM(Ice.IntOptional timeout, Ice.Optional<ACMClose> close, Ice.Optional<ACMHeartbeat> heartbeat) { @@ -703,8 +854,7 @@ public final class ConnectionI extends IceInternal.EventHandler public synchronized void invokeException(int requestId, LocalException ex, int invokeNum, boolean amd) { // - // Fatal exception while invoking a request. Since - // sendResponse/sendNoResponse isn't + // Fatal exception while invoking a request. Since sendResponse/sendNoResponse isn't // called in case of a fatal exception we decrement _dispatchCount here. // @@ -968,7 +1118,7 @@ public final class ConnectionI extends IceInternal.EventHandler } else { - assert (_state <= StateClosingPending); + assert(_state <= StateClosingPending); // // We parse messages first, if we receive a close @@ -1144,7 +1294,8 @@ public final class ConnectionI extends IceInternal.EventHandler // if(info.invokeNum > 0) { - invokeAll(info.stream, info.invokeNum, info.requestId, info.compress, info.servantManager, info.adapter); + invokeAll(info.stream, info.invokeNum, info.requestId, info.compress, info.servantManager, + info.adapter); // // Don't increase dispatchedCount, the dispatch count is @@ -1301,7 +1452,7 @@ public final class ConnectionI extends IceInternal.EventHandler // Trace the cause of unexpected connection closures // if(!(_exception instanceof CloseConnectionException || - _exception instanceof ForcedCloseConnectionException || + _exception instanceof ConnectionManuallyClosedException || _exception instanceof ConnectionTimeoutException || _exception instanceof CommunicatorDestroyedException || _exception instanceof ObjectAdapterDeactivatedException)) @@ -1650,7 +1801,7 @@ public final class ConnectionI extends IceInternal.EventHandler // Don't warn about certain expected exceptions. // if(!(_exception instanceof CloseConnectionException || - _exception instanceof ForcedCloseConnectionException || + _exception instanceof ConnectionManuallyClosedException || _exception instanceof ConnectionTimeoutException || _exception instanceof CommunicatorDestroyedException || _exception instanceof ObjectAdapterDeactivatedException || @@ -1840,7 +1991,7 @@ public final class ConnectionI extends IceInternal.EventHandler if(_observer != null && state == StateClosed && _exception != null) { if(!(_exception instanceof CloseConnectionException || - _exception instanceof ForcedCloseConnectionException || + _exception instanceof ConnectionManuallyClosedException || _exception instanceof ConnectionTimeoutException || _exception instanceof CommunicatorDestroyedException || _exception instanceof ObjectAdapterDeactivatedException || @@ -1869,8 +2020,7 @@ public final class ConnectionI extends IceInternal.EventHandler private void initiateShutdown() { - assert (_state == StateClosing); - assert (_dispatchCount == 0); + assert(_state == StateClosing && _dispatchCount == 0); if(_shutdownInitiated) { @@ -1897,8 +2047,7 @@ public final class ConnectionI extends IceInternal.EventHandler setState(StateClosingPending); // - // Notify the the transceiver of the graceful connection - // closure. + // Notify the the transceiver of the graceful connection closure. // int op = _transceiver.closing(true, _exception); if(op != 0) @@ -1910,7 +2059,7 @@ public final class ConnectionI extends IceInternal.EventHandler } } - private void heartbeat() + private void sendHeartbeatNow() { assert (_state == StateActive); @@ -1948,8 +2097,7 @@ public final class ConnectionI extends IceInternal.EventHandler } // - // Update the connection description once the transceiver is - // initialized. + // Update the connection description once the transceiver is initialized. // _desc = _transceiver.toString(); _initialized = true; @@ -2108,8 +2256,7 @@ public final class ConnectionI extends IceInternal.EventHandler } else if(_state == StateClosingPending && _writeStream.pos() == 0) { - // Message wasn't sent, empty the _writeStream, we're not going to - // send more data. + // Message wasn't sent, empty the _writeStream, we're not going to send more data. OutgoingMessage message = _sendStreams.getFirst(); _writeStream.swap(message.stream); return IceInternal.SocketOperation.None; @@ -2416,8 +2563,7 @@ public final class ConnectionI extends IceInternal.EventHandler setState(StateClosingPending, new CloseConnectionException()); // - // Notify the the transceiver of the graceful connection - // closure. + // Notify the the transceiver of the graceful connection closure. // int op = _transceiver.closing(false, _exception); if(op != 0) diff --git a/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java b/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java index 9405e3dcc17..108df4607e0 100644 --- a/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java +++ b/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java @@ -141,7 +141,7 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice // for(Ice.ConnectionI c : connections) { - c.close(true); + c.close(Ice.ConnectionClose.CloseForcefully); } throw e; } diff --git a/java-compat/src/Ice/src/main/java/IceInternal/OutgoingConnectionFactory.java b/java-compat/src/Ice/src/main/java/IceInternal/OutgoingConnectionFactory.java index 94b80c0e2fb..b51856cf3e6 100644 --- a/java-compat/src/Ice/src/main/java/IceInternal/OutgoingConnectionFactory.java +++ b/java-compat/src/Ice/src/main/java/IceInternal/OutgoingConnectionFactory.java @@ -133,7 +133,7 @@ public final class OutgoingConnectionFactory { for(Ice.ConnectionI c : l) { - c.close(true); + c.close(Ice.ConnectionClose.CloseForcefully); } } throw new Ice.OperationInterruptedException(); diff --git a/java-compat/test/src/main/java/test/Ice/acm/AllTests.java b/java-compat/test/src/main/java/test/Ice/acm/AllTests.java index a4369b684b8..05465c8e3cb 100644 --- a/java-compat/test/src/main/java/test/Ice/acm/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/acm/AllTests.java @@ -575,6 +575,31 @@ public class AllTests } } + static class HeartbeatManualTest extends TestCase + { + public HeartbeatManualTest(Application app, RemoteCommunicatorPrx com, java.io.PrintWriter out) + { + super(app, "manual heartbeats", com, out); + // + // Disable heartbeats. + // + setClientACM(10, -1, 0); + setServerACM(10, -1, 0); + } + + public void runTestCase(RemoteObjectAdapterPrx adapter, TestIntfPrx proxy) + { + proxy.startHeartbeatCount(); + Ice.Connection con = proxy.ice_getConnection(); + con.heartbeat(); + con.heartbeat(); + con.heartbeat(); + con.heartbeat(); + con.heartbeat(); + proxy.waitForHeartbeatCount(5); + } + } + static class SetACMTest extends TestCase { public SetACMTest(Application app, RemoteCommunicatorPrx com, java.io.PrintWriter out) @@ -607,7 +632,8 @@ public class AllTests test(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatAlways); // Make sure the client sends few heartbeats to the server - proxy.waitForHeartbeat(2); + proxy.startHeartbeatCount(); + proxy.waitForHeartbeatCount(2); } } @@ -634,6 +660,7 @@ public class AllTests tests.add(new HeartbeatOnIdleTest(app, com, out)); tests.add(new HeartbeatAlwaysTest(app, com, out)); + tests.add(new HeartbeatManualTest(app, com, out)); tests.add(new SetACMTest(app, com, out)); for(TestCase test : tests) diff --git a/java-compat/test/src/main/java/test/Ice/acm/Test.ice b/java-compat/test/src/main/java/test/Ice/acm/Test.ice index 117192a2df8..7f71427c741 100644 --- a/java-compat/test/src/main/java/test/Ice/acm/Test.ice +++ b/java-compat/test/src/main/java/test/Ice/acm/Test.ice @@ -18,7 +18,8 @@ interface TestIntf void sleep(int seconds); void sleepAndHold(int seconds); void interruptSleep(); - void waitForHeartbeat(int count); + void startHeartbeatCount(); + void waitForHeartbeatCount(int count); }; interface RemoteObjectAdapter diff --git a/java-compat/test/src/main/java/test/Ice/acm/TestI.java b/java-compat/test/src/main/java/test/Ice/acm/TestI.java index 00620c07dd0..a83cb645525 100644 --- a/java-compat/test/src/main/java/test/Ice/acm/TestI.java +++ b/java-compat/test/src/main/java/test/Ice/acm/TestI.java @@ -49,27 +49,34 @@ public class TestI extends _TestIntfDisp } } - public void waitForHeartbeat(int count, Ice.Current current) + public void startHeartbeatCount(Ice.Current current) { - final Ice.Holder<Integer> c = new Ice.Holder<Integer>(count); + _counter = new Ice.Holder<Integer>(0); Ice.HeartbeatCallback callback = new Ice.HeartbeatCallback() { - synchronized public void heartbeat(Ice.Connection connection) + public void heartbeat(Ice.Connection connection) { - --c.value; - notifyAll(); + synchronized(_counter) + { + ++_counter.value; + _counter.notifyAll(); + } } }; current.con.setHeartbeatCallback(callback); + } - synchronized(callback) + public void waitForHeartbeatCount(int count, Ice.Current current) + { + assert(_counter != null); + synchronized(_counter) { - while(c.value > 0) + while(_counter.value < count) { try { - callback.wait(); + _counter.wait(); } catch(InterruptedException ex) { @@ -77,4 +84,6 @@ public class TestI extends _TestIntfDisp } } } -}; + + private Ice.Holder<Integer> _counter; +} diff --git a/java-compat/test/src/main/java/test/Ice/ami/AMI.java b/java-compat/test/src/main/java/test/Ice/ami/AMI.java index c018ccb8c62..c707f20e6c7 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/AMI.java +++ b/java-compat/test/src/main/java/test/Ice/ami/AMI.java @@ -19,6 +19,7 @@ import test.Ice.ami.Test.Callback_TestIntf_op; import test.Ice.ami.Test.Callback_TestIntf_opWithResult; import test.Ice.ami.Test.Callback_TestIntf_opWithUE; import test.Ice.ami.Test.Callback_TestIntf_opWithPayload; +import test.Ice.ami.Test.CloseMode; import test.Util.Application; public class AMI @@ -546,6 +547,18 @@ public class AMI } } + static class CloseCallback extends CallbackBase implements Ice.CloseCallback + { + CloseCallback() + { + } + + public void closed(Ice.Connection con) + { + called(); + } + } + enum ThrowType { LocalException, OtherException }; static class Thrower extends CallbackBase @@ -1817,7 +1830,7 @@ public class AMI test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( new Ice.Callback() @@ -1879,7 +1892,7 @@ public class AMI TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.ice_getConnection(); b1.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( new Ice.Callback_Object_ice_flushBatchRequests() @@ -1948,7 +1961,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( new Ice.Callback() @@ -2010,7 +2023,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( new Ice.Callback_Connection_flushBatchRequests() @@ -2077,7 +2090,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( new Ice.Callback() @@ -2151,7 +2164,7 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( new Ice.Callback() @@ -2188,8 +2201,8 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(false); - b2.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( new Ice.Callback() @@ -2251,7 +2264,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast( p.ice_getConnection().createProxy(p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( new Ice.Callback_Communicator_flushBatchRequests() @@ -2325,7 +2338,7 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( new Ice.Callback_Communicator_flushBatchRequests() @@ -2362,8 +2375,8 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(false); - b2.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( new Ice.Callback_Communicator_flushBatchRequests() @@ -2588,9 +2601,36 @@ public class AMI if(p.ice_getConnection() != null) { - out.print("testing close connection with sending queue... "); + out.print("testing graceful close connection with wait... "); out.flush(); { + // + // Local case: begin several requests, close the connection gracefully, and make sure it waits + // for the requests to complete. + // + java.util.List<Ice.AsyncResult> results = new java.util.ArrayList<>(); + for(int i = 0; i < 3; ++i) + { + results.add(p.begin_sleep(50)); + } + p.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + for(Ice.AsyncResult r : results) + { + r.waitForCompleted(); + try + { + r.throwLocalException(); + } + catch(Throwable ex) + { + test(false); + } + } + } + { + // + // Remote case. + // byte[] seq = new byte[1024 * 10]; // @@ -2604,12 +2644,12 @@ public class AMI { done = true; p.ice_ping(); - java.util.List<Ice.AsyncResult> results = new java.util.ArrayList<Ice.AsyncResult>(); + java.util.List<Ice.AsyncResult> results = new java.util.ArrayList<>(); for(int i = 0; i < maxQueue; ++i) { results.add(p.begin_opWithPayload(seq)); } - if(!p.begin_close(false).isSent()) + if(!p.begin_close(CloseMode.CloseGracefullyAndWait).isSent()) { for(int i = 0; i < maxQueue; i++) { @@ -2643,6 +2683,98 @@ public class AMI } } out.println("ok"); + + out.print("testing graceful close connection without wait... "); + out.flush(); + { + // + // Local case: start a lengthy operation and then close the connection gracefully on the client side + // without waiting for the pending invocation to complete. There will be no retry and we expect the + // invocation to fail with ConnectionManuallyClosedException. + // + // This test requires two threads in the server's thread pool: one will block in sleep() and the other + // will process the CloseConnection message. + // + p.ice_ping(); + Ice.Connection con = p.ice_getConnection(); + Ice.AsyncResult r = p.begin_sleep(100); + con.close(Ice.ConnectionClose.CloseGracefully); + r.waitForCompleted(); + try + { + r.throwLocalException(); + test(false); + } + catch(Ice.ConnectionManuallyClosedException ex) + { + test(ex.graceful); + } + + // + // Remote case: the server closes the connection gracefully. Our call to TestIntf::close() + // completes successfully and then the connection should be closed immediately afterward, + // despite the fact that there's a pending call to sleep(). The call to sleep() should be + // automatically retried and complete successfully. + // + p.ice_ping(); + con = p.ice_getConnection(); + CloseCallback cb = new CloseCallback(); + con.setCloseCallback(cb); + r = p.begin_sleep(100); + p.close(CloseMode.CloseGracefully); + cb.check(); + r.waitForCompleted(); + try + { + r.throwLocalException(); + } + catch(Ice.LocalException ex) + { + test(false); + } + p.ice_ping(); + test(p.ice_getConnection() != con); + } + out.println("ok"); + + out.print("testing forceful close connection... "); + out.flush(); + { + // + // Local case: start a lengthy operation and then close the connection forcefully on the client side. + // There will be no retry and we expect the invocation to fail with ConnectionManuallyClosedException. + // + p.ice_ping(); + Ice.Connection con = p.ice_getConnection(); + Ice.AsyncResult r = p.begin_sleep(100); + con.close(Ice.ConnectionClose.CloseForcefully); + r.waitForCompleted(); + try + { + r.throwLocalException(); + test(false); + } + catch(Ice.ConnectionManuallyClosedException ex) + { + test(!ex.graceful); + } + + // + // Remote case: the server closes the connection forcefully. This causes the request to fail + // with a ConnectionLostException. Since the close() operation is not idempotent, the client + // will not retry. + // + try + { + p.close(CloseMode.CloseForcefully); + test(false); + } + catch(Ice.ConnectionLostException ex) + { + // Expected. + } + } + out.println("ok"); } } } diff --git a/java-compat/test/src/main/java/test/Ice/ami/Client.java b/java-compat/test/src/main/java/test/Ice/ami/Client.java index 097bb922ce6..b261e603777 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/Client.java +++ b/java-compat/test/src/main/java/test/Ice/ami/Client.java @@ -24,6 +24,7 @@ public class Client extends test.Util.Application Ice.InitializationData initData = super.getInitData(argsH); initData.properties.setProperty("Ice.Package.Test", "test.Ice.ami"); initData.properties.setProperty("Ice.Warn.AMICallback", "0"); + initData.properties.setProperty("Ice.Warn.Connections", "0"); // // Limit the send buffer size, this test relies on the socket diff --git a/java-compat/test/src/main/java/test/Ice/ami/Server.java b/java-compat/test/src/main/java/test/Ice/ami/Server.java index 1b826ef52e9..62dfc59af45 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/Server.java +++ b/java-compat/test/src/main/java/test/Ice/ami/Server.java @@ -34,6 +34,12 @@ public class Server extends test.Util.Application initData.properties.setProperty("TestAdapter.Endpoints", getTestEndpoint(initData.properties, 0)); initData.properties.setProperty("ControllerAdapter.Endpoints", getTestEndpoint(initData.properties, 1)); initData.properties.setProperty("ControllerAdapter.ThreadPool.Size", "1"); + + // + // This test kills connections, so we don't want warnings. + // + initData.properties.setProperty("Ice.Warn.Connections", "0"); + // // Limit the recv buffer size, this test relies on the socket // send() blocking after sending a given amount of data. diff --git a/java-compat/test/src/main/java/test/Ice/ami/Test.ice b/java-compat/test/src/main/java/test/Ice/ami/Test.ice index 82b3fe6d383..bbc4d908d65 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/Test.ice +++ b/java-compat/test/src/main/java/test/Ice/ami/Test.ice @@ -20,6 +20,13 @@ exception TestIntfException { }; +enum CloseMode +{ + CloseForcefully, + CloseGracefully, + CloseGracefullyAndWait +}; + interface TestIntf { void op(); @@ -30,7 +37,8 @@ interface TestIntf void opBatch(); int opBatchCount(); bool waitForBatch(int count); - void close(bool force); + void close(CloseMode mode); + void sleep(int ms); void shutdown(); bool supportsFunctionalTests(); diff --git a/java-compat/test/src/main/java/test/Ice/ami/TestI.java b/java-compat/test/src/main/java/test/Ice/ami/TestI.java index b0c6df0cf4a..af4c50e5d33 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/TestI.java +++ b/java-compat/test/src/main/java/test/Ice/ami/TestI.java @@ -10,6 +10,7 @@ package test.Ice.ami; import test.Ice.ami.Test._TestIntfDisp; +import test.Ice.ami.Test.CloseMode; import test.Ice.ami.Test.TestIntfException; public class TestI extends _TestIntfDisp @@ -129,9 +130,22 @@ public class TestI extends _TestIntfDisp @Override public void - close(boolean force, Ice.Current current) + close(CloseMode mode, Ice.Current current) { - current.con.close(force); + current.con.close(Ice.ConnectionClose.valueOf(mode.value())); + } + + @Override + public void + sleep(int ms, Ice.Current current) + { + try + { + Thread.sleep(ms); + } + catch(InterruptedException ex) + { + } } @Override diff --git a/java-compat/test/src/main/java/test/Ice/ami/lambda/AMI.java b/java-compat/test/src/main/java/test/Ice/ami/lambda/AMI.java index eb572f481e2..8d886c20d78 100644 --- a/java-compat/test/src/main/java/test/Ice/ami/lambda/AMI.java +++ b/java-compat/test/src/main/java/test/Ice/ami/lambda/AMI.java @@ -845,7 +845,7 @@ public class AMI test(p.opBatchCount() == 0); TestIntfPrx b1 = (TestIntfPrx)p.ice_batchOneway(); b1.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = b1.begin_ice_flushBatchRequests( null, @@ -901,7 +901,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushExCallback cb = new FlushExCallback(); Ice.AsyncResult r = b1.ice_getConnection().begin_flushBatchRequests( null, @@ -946,7 +946,7 @@ public class AMI TestIntfPrx b1 = TestIntfPrxHelper.uncheckedCast(p.ice_getConnection().createProxy( p.ice_getIdentity()).ice_batchOneway()); b1.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( null, @@ -998,7 +998,7 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( null, @@ -1024,8 +1024,8 @@ public class AMI b2.ice_getConnection(); // Ensure connection is established. b1.opBatch(); b2.opBatch(); - b1.ice_getConnection().close(false); - b2.ice_getConnection().close(false); + b1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + b2.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final FlushCallback cb = new FlushCallback(); Ice.AsyncResult r = communicator.begin_flushBatchRequests( null, diff --git a/java-compat/test/src/main/java/test/Ice/background/AllTests.java b/java-compat/test/src/main/java/test/Ice/background/AllTests.java index 187c7bbf4f2..e3f92a9f4d9 100644 --- a/java-compat/test/src/main/java/test/Ice/background/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/background/AllTests.java @@ -398,7 +398,7 @@ public class AllTests configuration.buffered(true); backgroundController.buffered(true); background.begin_op(); - background.ice_getCachedConnection().close(true); + background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); background.begin_op(); OpAMICallbackNoOp cb = new OpAMICallbackNoOp(); @@ -439,7 +439,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(false); + background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); for(int i = 0; i < 4; ++i) { @@ -505,7 +505,7 @@ public class AllTests } configuration.connectException(new Ice.SocketException()); - background.ice_getCachedConnection().close(true); + background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); try { Thread.sleep(10); @@ -548,7 +548,7 @@ public class AllTests ex.printStackTrace(); test(false); } - background.ice_getConnection().close(false); + background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); for(int i = 0; i < 4; i++) { @@ -611,7 +611,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(false); + background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); try { @@ -623,7 +623,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(false); + background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); try { @@ -667,7 +667,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(false); + background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); try { @@ -702,7 +702,7 @@ public class AllTests } configuration.initializeException(new Ice.SocketException()); - background.ice_getCachedConnection().close(true); + background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); try { Thread.sleep(10); @@ -728,7 +728,7 @@ public class AllTests } configuration.initializeSocketStatus(IceInternal.SocketOperation.Write); - background.ice_getCachedConnection().close(true); + background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); try { @@ -743,7 +743,7 @@ public class AllTests configuration.initializeSocketStatus(IceInternal.SocketOperation.None); ctl.initializeException(true); - background.ice_getCachedConnection().close(true); + background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); try { Thread.sleep(10); @@ -771,7 +771,7 @@ public class AllTests try { ctl.initializeSocketStatus(IceInternal.SocketOperation.Write); - background.ice_getCachedConnection().close(true); + background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); background.op(); ctl.initializeSocketStatus(IceInternal.SocketOperation.None); } @@ -806,7 +806,7 @@ public class AllTests { test(false); } - background.ice_getConnection().close(false); + background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); try { @@ -852,7 +852,7 @@ public class AllTests ex.printStackTrace(); test(false); } - background.ice_getConnection().close(false); + background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); try { @@ -922,7 +922,7 @@ public class AllTests ex.printStackTrace(); test(false); } - background.ice_getConnection().close(false); + background.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); try { @@ -952,7 +952,7 @@ public class AllTests backgroundBatchOneway.op(); ctl.resumeAdapter(); backgroundBatchOneway.ice_flushBatchRequests(); - backgroundBatchOneway.ice_getConnection().close(false); + backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); // // Send bigger requests to test with auto-flushing. @@ -964,7 +964,7 @@ public class AllTests backgroundBatchOneway.opWithPayload(seq); ctl.resumeAdapter(); backgroundBatchOneway.ice_flushBatchRequests(); - backgroundBatchOneway.ice_getConnection().close(false); + backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); // // Then try the same thing with async flush. @@ -976,7 +976,7 @@ public class AllTests backgroundBatchOneway.op(); ctl.resumeAdapter(); backgroundBatchOneway.begin_ice_flushBatchRequests(); - backgroundBatchOneway.ice_getConnection().close(false); + backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); ctl.holdAdapter(); backgroundBatchOneway.opWithPayload(seq); @@ -986,7 +986,7 @@ public class AllTests ctl.resumeAdapter(); r = backgroundBatchOneway.begin_ice_flushBatchRequests(); backgroundBatchOneway.end_ice_flushBatchRequests(r); - backgroundBatchOneway.ice_getConnection().close(false); + backgroundBatchOneway.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } private static void @@ -1328,7 +1328,7 @@ public class AllTests } background.ice_ping(); - background.ice_getCachedConnection().close(true); + background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); try { Thread.sleep(10); @@ -1337,7 +1337,7 @@ public class AllTests { } - background.ice_getCachedConnection().close(true); + background.ice_getCachedConnection().close(Ice.ConnectionClose.CloseForcefully); } thread1._destroy(); diff --git a/java-compat/test/src/main/java/test/Ice/binding/AllTests.java b/java-compat/test/src/main/java/test/Ice/binding/AllTests.java index 4aadfe0c3ff..062a5c87393 100644 --- a/java-compat/test/src/main/java/test/Ice/binding/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/binding/AllTests.java @@ -176,7 +176,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(test1.getAdapterName()); - test1.ice_getConnection().close(false); + test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } // @@ -198,7 +198,7 @@ public class AllTests for(RemoteObjectAdapterPrx p : adapters) { - p.getTestIntf().ice_getConnection().close(false); + p.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } } @@ -224,7 +224,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(test1.getAdapterName()); - test1.ice_getConnection().close(false); + test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } // @@ -332,7 +332,7 @@ public class AllTests { try { - a.getTestIntf().ice_getConnection().close(false); + a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } catch(Ice.LocalException ex) { @@ -374,7 +374,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(getAdapterNameWithAMI(test1)); - test1.ice_getConnection().close(false); + test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } // @@ -396,7 +396,7 @@ public class AllTests for(RemoteObjectAdapterPrx p : adapters) { - p.getTestIntf().ice_getConnection().close(false); + p.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } } @@ -422,7 +422,7 @@ public class AllTests test(test2.ice_getConnection() == test3.ice_getConnection()); names.remove(getAdapterNameWithAMI(test1)); - test1.ice_getConnection().close(false); + test1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } // @@ -455,7 +455,7 @@ public class AllTests while(!names.isEmpty()) { names.remove(test.getAdapterName()); - test.ice_getConnection().close(false); + test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } test = TestIntfPrxHelper.uncheckedCast(test.ice_endpointSelection(Ice.EndpointSelectionType.Random)); @@ -467,7 +467,7 @@ public class AllTests while(!names.isEmpty()) { names.remove(test.getAdapterName()); - test.ice_getConnection().close(false); + test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } deactivate(com, adapters); @@ -531,11 +531,11 @@ public class AllTests adapters.add(com.createObjectAdapter("Adapter36", endpoints[2].toString())); for(i = 0; i < nRetry && test.getAdapterName().equals("Adapter36"); i++); test(i == nRetry); - test.ice_getConnection().close(false); + test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); adapters.add(com.createObjectAdapter("Adapter35", endpoints[1].toString())); for(i = 0; i < nRetry && test.getAdapterName().equals("Adapter35"); i++); test(i == nRetry); - test.ice_getConnection().close(false); + test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); adapters.add(com.createObjectAdapter("Adapter34", endpoints[0].toString())); for(i = 0; i < nRetry && test.getAdapterName().equals("Adapter34"); i++); test(i == nRetry); @@ -832,7 +832,7 @@ public class AllTests for(i = 0; i < 5; i++) { test(test.getAdapterName().equals("Adapter82")); - test.ice_getConnection().close(false); + test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } TestIntfPrx testSecure = TestIntfPrxHelper.uncheckedCast(test.ice_secure(true)); @@ -848,7 +848,7 @@ public class AllTests for(i = 0; i < 5; i++) { test(test.getAdapterName().equals("Adapter81")); - test.ice_getConnection().close(false); + test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } com.createObjectAdapter("Adapter83", (test.ice_getEndpoints()[1]).toString()); // Reactive tcp OA. @@ -856,7 +856,7 @@ public class AllTests for(i = 0; i < 5; i++) { test(test.getAdapterName().equals("Adapter83")); - test.ice_getConnection().close(false); + test.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } com.deactivateObjectAdapter(adapters.get(0)); @@ -1051,7 +1051,7 @@ public class AllTests // Close the connection now to free a FD (it could be done after the sleep but // there could be race condiutation since the connection might not be closed // immediately due to threading). - test.ice_connectionId("0").ice_getConnection().close(false); + test.ice_connectionId("0").ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); // // The server closed the acceptor, wait one second and retry after freeing a FD. diff --git a/java-compat/test/src/main/java/test/Ice/hold/AllTests.java b/java-compat/test/src/main/java/test/Ice/hold/AllTests.java index b27fbaf331c..bd642b9882f 100644 --- a/java-compat/test/src/main/java/test/Ice/hold/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/hold/AllTests.java @@ -206,7 +206,7 @@ public class AllTests { result.waitForSent(); holdSerialized.ice_ping(); // Ensure everything's dispatched - holdSerialized.ice_getConnection().close(false); + holdSerialized.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } } result.waitForCompleted(); diff --git a/java-compat/test/src/main/java/test/Ice/interrupt/AllTests.java b/java-compat/test/src/main/java/test/Ice/interrupt/AllTests.java index 8d954f051ec..ed523af5dbe 100644 --- a/java-compat/test/src/main/java/test/Ice/interrupt/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/interrupt/AllTests.java @@ -379,8 +379,7 @@ public class AllTests out.flush(); { final Thread mainThread = Thread.currentThread(); - - p.ice_getConnection().close(false); + p.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); AsyncResult r = p.begin_ice_getConnection(); mainThread.interrupt(); @@ -394,7 +393,7 @@ public class AllTests // Expected } - p.ice_getConnection().close(false); + p.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); final CallbackBase cb = new CallbackBase(); mainThread.interrupt(); diff --git a/java-compat/test/src/main/java/test/Ice/location/AllTests.java b/java-compat/test/src/main/java/test/Ice/location/AllTests.java index 8b6d3fb74ee..f8a3ab46d65 100644 --- a/java-compat/test/src/main/java/test/Ice/location/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/location/AllTests.java @@ -611,7 +611,7 @@ public class AllTests out.flush(); hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); obj.migrateHello(); - hello.ice_getConnection().close(false); + hello.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); hello.sayHello(); obj.migrateHello(); hello.sayHello(); diff --git a/java-compat/test/src/main/java/test/Ice/metrics/AMDMetricsI.java b/java-compat/test/src/main/java/test/Ice/metrics/AMDMetricsI.java index 865db0c83ef..42bb7ee43d7 100644 --- a/java-compat/test/src/main/java/test/Ice/metrics/AMDMetricsI.java +++ b/java-compat/test/src/main/java/test/Ice/metrics/AMDMetricsI.java @@ -28,7 +28,7 @@ public final class AMDMetricsI extends _MetricsDisp public void fail_async(AMD_Metrics_fail cb, Ice.Current current) { - current.con.close(true); + current.con.close(Ice.ConnectionClose.CloseForcefully); cb.ice_response(); } diff --git a/java-compat/test/src/main/java/test/Ice/metrics/AllTests.java b/java-compat/test/src/main/java/test/Ice/metrics/AllTests.java index ea00e4fc8dd..52de5aef9c1 100644 --- a/java-compat/test/src/main/java/test/Ice/metrics/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/metrics/AllTests.java @@ -313,7 +313,7 @@ public class AllTests { if(proxy.ice_getCachedConnection() != null) { - proxy.ice_getCachedConnection().close(false); + proxy.ice_getCachedConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } try @@ -326,7 +326,7 @@ public class AllTests if(proxy.ice_getCachedConnection() != null) { - proxy.ice_getCachedConnection().close(false); + proxy.ice_getCachedConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); } } @@ -545,8 +545,8 @@ public class AllTests if(!collocated) { - metrics.ice_getConnection().close(false); - metrics.ice_connectionId("Con1").ice_getConnection().close(false); + metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); + metrics.ice_connectionId("Con1").ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); @@ -649,7 +649,7 @@ public class AllTests map = toMap(serverMetrics.getMetricsView("View", timestamp).get("Connection")); test(map.get("holding").current == 1); - metrics.ice_getConnection().close(false); + metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); map = toMap(clientMetrics.getMetricsView("View", timestamp).get("Connection")); test(map.get("closing").current == 1); @@ -664,7 +664,7 @@ public class AllTests props.put("IceMX.Metrics.View.Map.Connection.GroupBy", "none"); updateProps(clientProps, serverProps, update, props, "Connection"); - metrics.ice_getConnection().close(false); + metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); metrics.ice_timeout(500).ice_ping(); controller.hold(); @@ -726,7 +726,7 @@ public class AllTests testAttribute(clientMetrics, clientProps, update, "Connection", "mcastHost", "", out); testAttribute(clientMetrics, clientProps, update, "Connection", "mcastPort", "", out); - m.ice_getConnection().close(false); + m.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); waitForCurrent(clientMetrics, "View", "Connection", 0); waitForCurrent(serverMetrics, "View", "Connection", 0); @@ -746,7 +746,7 @@ public class AllTests IceMX.Metrics m1 = clientMetrics.getMetricsView("View", timestamp).get("ConnectionEstablishment")[0]; test(m1.current == 0 && m1.total == 1 && m1.id.equals(hostAndPort)); - metrics.ice_getConnection().close(false); + metrics.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); controller.hold(); try { @@ -806,7 +806,7 @@ public class AllTests m1 = clientMetrics.getMetricsView("View", timestamp).get("EndpointLookup")[0]; test(m1.current <= 1 && m1.total == 1 && m1.id.equals(prx.ice_getConnection().getEndpoint().toString())); - prx.ice_getConnection().close(false); + prx.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); boolean dnsException = false; try diff --git a/java-compat/test/src/main/java/test/Ice/metrics/MetricsI.java b/java-compat/test/src/main/java/test/Ice/metrics/MetricsI.java index a7cf0f3dccf..37a3a440351 100644 --- a/java-compat/test/src/main/java/test/Ice/metrics/MetricsI.java +++ b/java-compat/test/src/main/java/test/Ice/metrics/MetricsI.java @@ -27,7 +27,7 @@ public final class MetricsI extends _MetricsDisp public void fail(Ice.Current current) { - current.con.close(true); + current.con.close(Ice.ConnectionClose.CloseForcefully); } @Override diff --git a/java-compat/test/src/main/java/test/Ice/operations/BatchOneways.java b/java-compat/test/src/main/java/test/Ice/operations/BatchOneways.java index 75ed24a392e..d3240fc5a06 100644 --- a/java-compat/test/src/main/java/test/Ice/operations/BatchOneways.java +++ b/java-compat/test/src/main/java/test/Ice/operations/BatchOneways.java @@ -115,7 +115,7 @@ class BatchOneways batch1.ice_ping(); batch2.ice_ping(); batch1.ice_flushBatchRequests(); - batch1.ice_getConnection().close(false); + batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); batch1.ice_ping(); batch2.ice_ping(); @@ -123,7 +123,7 @@ class BatchOneways batch2.ice_getConnection(); batch1.ice_ping(); - batch1.ice_getConnection().close(false); + batch1.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); batch1.ice_ping(); batch2.ice_ping(); } diff --git a/java-compat/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java b/java-compat/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java index 34d0cc00a43..985abb4e945 100644 --- a/java-compat/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java +++ b/java-compat/test/src/main/java/test/Ice/operations/BatchOnewaysAMI.java @@ -107,7 +107,7 @@ class BatchOnewaysAMI batch.begin_ice_ping(); batch2.begin_ice_ping(); batch.end_ice_flushBatchRequests(batch.begin_ice_flushBatchRequests()); - batch.ice_getConnection().close(false); + batch.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); batch.begin_ice_ping(); batch2.begin_ice_ping(); @@ -115,7 +115,7 @@ class BatchOnewaysAMI batch2.ice_getConnection(); batch.begin_ice_ping(); - batch.ice_getConnection().close(false); + batch.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); batch.begin_ice_ping().throwLocalException(); batch2.begin_ice_ping().throwLocalException(); } diff --git a/java-compat/test/src/main/java/test/Ice/retry/RetryI.java b/java-compat/test/src/main/java/test/Ice/retry/RetryI.java index 453b1ddd2c7..ab0d3ec70f7 100644 --- a/java-compat/test/src/main/java/test/Ice/retry/RetryI.java +++ b/java-compat/test/src/main/java/test/Ice/retry/RetryI.java @@ -25,7 +25,7 @@ public final class RetryI extends _RetryDisp { if(current.con != null) { - current.con.close(true); + current.con.close(Ice.ConnectionClose.CloseForcefully); } else { diff --git a/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java b/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java index 4c92ee8885b..28172f950c3 100644 --- a/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/timeout/AllTests.java @@ -329,7 +329,7 @@ public class AllTests TimeoutPrx to = TimeoutPrxHelper.checkedCast(obj.ice_timeout(100 * mult)); Ice.Connection connection = to.ice_getConnection(); timeout.holdAdapter(500); - connection.close(false); + connection.close(Ice.ConnectionClose.CloseGracefullyAndWait); try { connection.getInfo(); // getInfo() doesn't throw in the closing state. @@ -350,9 +350,10 @@ public class AllTests connection.getInfo(); test(false); } - catch(Ice.CloseConnectionException ex) + catch(Ice.ConnectionManuallyClosedException ex) { // Expected. + test(ex.graceful); } timeout.op(); // Ensure adapter is active. } diff --git a/java-compat/test/src/main/java/test/Ice/udp/AllTests.java b/java-compat/test/src/main/java/test/Ice/udp/AllTests.java index 22e8c47e0ae..5d000d818d0 100644 --- a/java-compat/test/src/main/java/test/Ice/udp/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/udp/AllTests.java @@ -130,7 +130,7 @@ public class AllTests { test(seq.length > 16384); } - obj.ice_getConnection().close(false); + obj.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); communicator.getProperties().setProperty("Ice.UDP.SndSize", "64000"); seq = new byte[50000]; try diff --git a/java-compat/test/src/main/java/test/IceSSL/configuration/AllTests.java b/java-compat/test/src/main/java/test/IceSSL/configuration/AllTests.java index 6e836a3f832..a13868fbeb8 100644 --- a/java-compat/test/src/main/java/test/IceSSL/configuration/AllTests.java +++ b/java-compat/test/src/main/java/test/IceSSL/configuration/AllTests.java @@ -891,7 +891,7 @@ public class AllTests // verifier.reset(); verifier.returnValue(false); - server.ice_getConnection().close(false); + server.ice_getConnection().close(Ice.ConnectionClose.CloseGracefullyAndWait); try { server.ice_ping(); |