summaryrefslogtreecommitdiff
path: root/java-compat
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2019-09-03 16:54:16 +0200
committerBenoit Foucher <benoit@zeroc.com>2019-09-03 16:54:28 +0200
commit3a0366354071a3acfdf93158732938f943339d65 (patch)
treeaf319b72556ba9736063447f48dc5324a0c57c81 /java-compat
parentFixes for slice2py forward declarations - Close #490 (diff)
downloadice-3a0366354071a3acfdf93158732938f943339d65.tar.bz2
ice-3a0366354071a3acfdf93158732938f943339d65.tar.xz
ice-3a0366354071a3acfdf93158732938f943339d65.zip
Fixed retry bug with -2 invocation timeout, fixes #501
Diffstat (limited to 'java-compat')
-rw-r--r--java-compat/src/Ice/src/main/java/IceInternal/AsyncResultI.java2
-rw-r--r--java-compat/src/Ice/src/main/java/IceInternal/ProxyOutgoingAsyncBase.java7
-rw-r--r--java-compat/test/src/main/java/test/Ice/retry/AllTests.java73
-rw-r--r--java-compat/test/src/main/java/test/Ice/retry/RetryI.java17
-rw-r--r--java-compat/test/src/main/java/test/Ice/retry/Test.ice2
5 files changed, 72 insertions, 29 deletions
diff --git a/java-compat/src/Ice/src/main/java/IceInternal/AsyncResultI.java b/java-compat/src/Ice/src/main/java/IceInternal/AsyncResultI.java
index 98cec6f21c6..c3953b64b68 100644
--- a/java-compat/src/Ice/src/main/java/IceInternal/AsyncResultI.java
+++ b/java-compat/src/Ice/src/main/java/IceInternal/AsyncResultI.java
@@ -399,9 +399,9 @@ public class AsyncResultI implements AsyncResult
CancellationHandler handler;
synchronized(this)
{
- _cancellationException = ex;
if(_cancellationHandler == null)
{
+ _cancellationException = ex;
return;
}
handler = _cancellationHandler;
diff --git a/java-compat/src/Ice/src/main/java/IceInternal/ProxyOutgoingAsyncBase.java b/java-compat/src/Ice/src/main/java/IceInternal/ProxyOutgoingAsyncBase.java
index 9fa8928bfec..b50772d3f24 100644
--- a/java-compat/src/Ice/src/main/java/IceInternal/ProxyOutgoingAsyncBase.java
+++ b/java-compat/src/Ice/src/main/java/IceInternal/ProxyOutgoingAsyncBase.java
@@ -45,6 +45,13 @@ public abstract class ProxyOutgoingAsyncBase extends OutgoingAsyncBase
_childObserver = null;
}
+ _cachedConnection = null;
+ if(_proxy._getReference().getInvocationTimeout() == -2 && _future != null)
+ {
+ _future.cancel(false);
+ _future = null;
+ }
+
//
// NOTE: at this point, synchronization isn't needed, no other threads should be
// calling on the callback.
diff --git a/java-compat/test/src/main/java/test/Ice/retry/AllTests.java b/java-compat/test/src/main/java/test/Ice/retry/AllTests.java
index e5d67017133..5d2f440e928 100644
--- a/java-compat/test/src/main/java/test/Ice/retry/AllTests.java
+++ b/java-compat/test/src/main/java/test/Ice/retry/AllTests.java
@@ -256,36 +256,53 @@ public class AllTests
out.println("ok");
}
- out.print("testing invocation timeout and retries... ");
- out.flush();
-
- retry2 = RetryPrxHelper.checkedCast(communicator2.stringToProxy(retry1.toString()));
- try
- {
- // No more than 2 retries before timeout kicks-in
- ((RetryPrx)retry2.ice_invocationTimeout(500)).opIdempotent(4);
- test(false);
- }
- catch(Ice.InvocationTimeoutException ex)
- {
- instrumentation.testRetryCount(2);
- retry2.opIdempotent(-1); // Reset the counter
- instrumentation.testRetryCount(-1);
- }
- try
{
- // No more than 2 retries before timeout kicks-in
- RetryPrx prx = (RetryPrx)retry2.ice_invocationTimeout(500);
- prx.end_opIdempotent(prx.begin_opIdempotent(4));
- test(false);
- }
- catch(Ice.InvocationTimeoutException ex)
- {
- instrumentation.testRetryCount(2);
- retry2.opIdempotent(-1); // Reset the counter
- instrumentation.testRetryCount(-1);
+ out.print("testing timeouts and retries... ");
+ out.flush();
+ retry2 = RetryPrxHelper.checkedCast(communicator2.stringToProxy(retry1.toString()));
+ try
+ {
+ // No more than 2 retries before timeout kicks-in
+ ((RetryPrx)retry2.ice_invocationTimeout(500)).opIdempotent(4);
+ test(false);
+ }
+ catch(Ice.InvocationTimeoutException ex)
+ {
+ instrumentation.testRetryCount(2);
+ retry2.opIdempotent(-1); // Reset the counter
+ instrumentation.testRetryCount(-1);
+ }
+ try
+ {
+ // No more than 2 retries before timeout kicks-in
+ RetryPrx prx = (RetryPrx)retry2.ice_invocationTimeout(500);
+ prx.end_opIdempotent(prx.begin_opIdempotent(4));
+ test(false);
+ }
+ catch(Ice.InvocationTimeoutException ex)
+ {
+ instrumentation.testRetryCount(2);
+ retry2.opIdempotent(-1); // Reset the counter
+ instrumentation.testRetryCount(-1);
+ }
+ if(retry1.ice_getConnection() != null)
+ {
+ // The timeout might occur on connection establishment or because of the sleep. What's
+ // important here is to make sure there are 4 retries and that no calls succeed to
+ // ensure retries with the old connection timeout semantics work.
+ RetryPrx retryWithTimeout = (RetryPrx)retry1.ice_invocationTimeout(-2).ice_timeout(200);
+ try
+ {
+ retryWithTimeout.sleep(300);
+ test(false);
+ }
+ catch(Ice.ConnectionTimeoutException ex)
+ {
+ }
+ instrumentation.testRetryCount(4);
+ }
+ out.println("ok");
}
- out.println("ok");
return retry1;
}
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 cd18ba98738..8fd2afda8a6 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
@@ -66,6 +66,23 @@ public final class RetryI extends _RetryDisp
@Override
public void
+ sleep(int delay, Ice.Current c)
+ {
+ while(true)
+ {
+ try
+ {
+ Thread.sleep(delay);
+ break;
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+ }
+
+ @Override
+ public void
shutdown(Ice.Current current)
{
current.adapter.getCommunicator().shutdown();
diff --git a/java-compat/test/src/main/java/test/Ice/retry/Test.ice b/java-compat/test/src/main/java/test/Ice/retry/Test.ice
index 173ded096d7..8df6a93e8cf 100644
--- a/java-compat/test/src/main/java/test/Ice/retry/Test.ice
+++ b/java-compat/test/src/main/java/test/Ice/retry/Test.ice
@@ -16,6 +16,8 @@ interface Retry
void opNotIdempotent();
void opSystemException();
+ idempotent void sleep(int delay);
+
idempotent void shutdown();
}