diff options
author | Jose <jose@zeroc.com> | 2019-07-18 23:51:08 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-07-18 23:51:08 +0200 |
commit | fc886b010c01cccb8cca3ac4d92f1ebd7fc72295 (patch) | |
tree | 51cf00a4a955efecc9c94527aeafcb25ffbe57b9 /java-compat | |
parent | Simplify OutputStream creation (diff) | |
parent | Fixed non-thread safe AMD dispatch, fixes #448 (#449) (diff) | |
download | ice-fc886b010c01cccb8cca3ac4d92f1ebd7fc72295.tar.bz2 ice-fc886b010c01cccb8cca3ac4d92f1ebd7fc72295.tar.xz ice-fc886b010c01cccb8cca3ac4d92f1ebd7fc72295.zip |
Merge remote-tracking branch 'origin/3.7' into swift
Diffstat (limited to 'java-compat')
9 files changed, 197 insertions, 11 deletions
diff --git a/java-compat/gradle/wrapper/gradle-wrapper.jar b/java-compat/gradle/wrapper/gradle-wrapper.jar Binary files differindex ed88a042a28..94336fcae91 100644 --- a/java-compat/gradle/wrapper/gradle-wrapper.jar +++ b/java-compat/gradle/wrapper/gradle-wrapper.jar diff --git a/java-compat/gradle/wrapper/gradle-wrapper.properties b/java-compat/gradle/wrapper/gradle-wrapper.properties index fb7ef980f26..290541c7386 100644 --- a/java-compat/gradle/wrapper/gradle-wrapper.properties +++ b/java-compat/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip diff --git a/java-compat/src/Ice/src/main/java/Ice/DispatchInterceptor.java b/java-compat/src/Ice/src/main/java/Ice/DispatchInterceptor.java index 8735ff7eea6..355e81dd354 100644 --- a/java-compat/src/Ice/src/main/java/Ice/DispatchInterceptor.java +++ b/java-compat/src/Ice/src/main/java/Ice/DispatchInterceptor.java @@ -43,5 +43,18 @@ public abstract class DispatchInterceptor extends ObjectImpl { return false; } + catch(java.lang.Throwable ex) + { + // + // If the input parameters weren't read, make sure we skip them here. It's needed to read the + // encoding version used by the client to eventually marshal the user exception. It's also needed + // if we dispatch a batch oneway request to read the next batch request. + // + if(current.encoding == null || (current.encoding.major == 0 && current.encoding.minor == 0)) + { + in.skipReadParams(); + } + throw ex; + } } } diff --git a/java-compat/test/src/main/java/test/Ice/interceptor/AMDInterceptorI.java b/java-compat/test/src/main/java/test/Ice/interceptor/AMDInterceptorI.java index ffade5fbac4..db208419d44 100644 --- a/java-compat/test/src/main/java/test/Ice/interceptor/AMDInterceptorI.java +++ b/java-compat/test/src/main/java/test/Ice/interceptor/AMDInterceptorI.java @@ -5,6 +5,7 @@ package test.Ice.interceptor; import test.Ice.interceptor.Test.RetryException; +import test.Ice.interceptor.Test.InvalidInputException; // // A dispatch interceptor with special handling for AMD requests @@ -23,6 +24,24 @@ class AMDInterceptorI extends InterceptorI implements Ice.DispatchInterceptorAsy throws Ice.UserException { Ice.Current current = request.getCurrent(); + + String context = current.ctx.get("raiseBeforeDispatch"); + if(context != null) + { + if(context.equals("user")) + { + throw new InvalidInputException(); + } + else if(context.equals("notExist")) + { + throw new Ice.ObjectNotExistException(); + } + else if(context.equals("system")) + { + throw new MySystemException(); + } + } + _lastOperation = current.operation; if(_lastOperation.equals("amdAddWithRetry")) @@ -51,8 +70,35 @@ class AMDInterceptorI extends InterceptorI implements Ice.DispatchInterceptorAsy request.getCurrent().ctx.put("retry", "no"); } + else if(current.ctx.get("retry") != null && current.ctx.get("retry").equals("yes")) + { + // + // Retry the dispatch to ensure that abandoning the result of the dispatch + // works fine and is thread-safe + // + _servant.ice_dispatch(request); + _servant.ice_dispatch(request); + } _lastStatus = _servant.ice_dispatch(request, this); + + context = current.ctx.get("raiseAfterDispatch"); + if(context != null) + { + if(context.equals("user")) + { + throw new InvalidInputException(); + } + else if(context.equals("notExist")) + { + throw new Ice.ObjectNotExistException(); + } + else if(context.equals("system")) + { + throw new MySystemException(); + } + } + return _lastStatus; } diff --git a/java-compat/test/src/main/java/test/Ice/interceptor/Client.java b/java-compat/test/src/main/java/test/Ice/interceptor/Client.java index d029404145e..2c95ccfdc21 100644 --- a/java-compat/test/src/main/java/test/Ice/interceptor/Client.java +++ b/java-compat/test/src/main/java/test/Ice/interceptor/Client.java @@ -96,6 +96,11 @@ public class Client extends test.TestHelper test(interceptor.getLastOperation().equals("amdAdd")); test(!interceptor.getLastStatus()); out.println("ok"); + + out.print("testing exceptions raised by the interceptor... "); + out.flush(); + testInterceptorExceptions(prx); + out.println("ok"); } private void @@ -114,6 +119,16 @@ public class Client extends test.TestHelper test(prx.amdAddWithRetry(33, 12) == 45); test(interceptor.getLastOperation().equals("amdAddWithRetry")); test(!interceptor.getLastStatus()); + { + java.util.Map<String, String> ctx = new java.util.HashMap<>(); + ctx.put("retry", "yes"); + for(int i = 0; i < 10; ++i) + { + test(prx.amdAdd(33, 12, ctx) == 45); + test(interceptor.getLastOperation().equals("amdAdd")); + test(!interceptor.getLastStatus()); + } + } out.println("ok"); out.print("testing user exception... "); out.flush(); @@ -169,6 +184,11 @@ public class Client extends test.TestHelper test(!interceptor.getLastStatus()); test(interceptor.getException() instanceof MySystemException); out.println("ok"); + + out.print("testing exceptions raised by the interceptor... "); + out.flush(); + testInterceptorExceptions(prx); + out.println("ok"); } public void run(String[] args) @@ -210,4 +230,63 @@ public class Client extends test.TestHelper runAmdTest(prxForAMD, amdInterceptor, out); } } + + private class ExceptionPoint + { + public ExceptionPoint(String point, String exception) + { + this.point = point; + this.exception = exception; + } + public String point; + public String exception; + }; + + private void testInterceptorExceptions(MyObjectPrx prx) + { + java.util.List<ExceptionPoint> exceptions = new java.util.ArrayList<ExceptionPoint>(); + exceptions.add(new ExceptionPoint("raiseBeforeDispatch", "user")); + exceptions.add(new ExceptionPoint("raiseBeforeDispatch", "notExist")); + exceptions.add(new ExceptionPoint("raiseBeforeDispatch", "system")); + exceptions.add(new ExceptionPoint("raiseAfterDispatch", "user")); + exceptions.add(new ExceptionPoint("raiseAfterDispatch", "notExist")); + exceptions.add(new ExceptionPoint("raiseAfterDispatch", "system")); + for(ExceptionPoint e : exceptions) + { + java.util.Map<String, String> ctx = new java.util.HashMap<String, String>(); + ctx.put(e.point, e.exception); + try + { + prx.ice_ping(ctx); + test(false); + } + catch(Ice.UnknownUserException ex) + { + test(e.exception.equals("user")); + } + catch(Ice.ObjectNotExistException ex) + { + test(e.exception.equals("notExist")); + } + catch(Ice.UnknownException ex) + { + test(e.exception.equals("system")); // non-collocated + } + catch(MySystemException ex) + { + test(e.exception.equals("system")); // collocated + } + { + Ice.ObjectPrx batch = prx.ice_batchOneway(); + batch.ice_ping(ctx); + batch.ice_ping(); + batch.ice_flushBatchRequests(); + + // Force the last batch request to be dispatched by the server thread using invocation timeouts + // This is required to preven threading issue with the test interceptor implementation which + // isn't thread safe + prx.ice_invocationTimeout(10000).ice_ping(); + } + } + } } diff --git a/java-compat/test/src/main/java/test/Ice/interceptor/InterceptorI.java b/java-compat/test/src/main/java/test/Ice/interceptor/InterceptorI.java index 547234e705b..0c067d65d66 100644 --- a/java-compat/test/src/main/java/test/Ice/interceptor/InterceptorI.java +++ b/java-compat/test/src/main/java/test/Ice/interceptor/InterceptorI.java @@ -5,6 +5,7 @@ package test.Ice.interceptor; import test.Ice.interceptor.Test.RetryException; +import test.Ice.interceptor.Test.InvalidInputException; class InterceptorI extends Ice.DispatchInterceptor { @@ -28,6 +29,24 @@ class InterceptorI extends Ice.DispatchInterceptor throws Ice.UserException { Ice.Current current = request.getCurrent(); + + String context = current.ctx.get("raiseBeforeDispatch"); + if(context != null) + { + if(context.equals("user")) + { + throw new InvalidInputException(); + } + else if(context.equals("notExist")) + { + throw new Ice.ObjectNotExistException(); + } + else if(context.equals("system")) + { + throw new MySystemException(); + } + } + _lastOperation = current.operation; if(_lastOperation.equals("addWithRetry")) @@ -51,6 +70,24 @@ class InterceptorI extends Ice.DispatchInterceptor } _lastStatus = _servant.ice_dispatch(request); + + context = current.ctx.get("raiseAfterDispatch"); + if(context != null) + { + if(context.equals("user")) + { + throw new InvalidInputException(); + } + else if(context.equals("notExist")) + { + throw new Ice.ObjectNotExistException(); + } + else if(context.equals("system")) + { + throw new MySystemException(); + } + } + return _lastStatus; } diff --git a/java-compat/test/src/main/java/test/Ice/interceptor/MyObjectI.java b/java-compat/test/src/main/java/test/Ice/interceptor/MyObjectI.java index 1f60cb0adb8..cebd1882ccd 100644 --- a/java-compat/test/src/main/java/test/Ice/interceptor/MyObjectI.java +++ b/java-compat/test/src/main/java/test/Ice/interceptor/MyObjectI.java @@ -65,6 +65,7 @@ class MyObjectI extends _MyObjectDisp public void amdAdd_async(final AMD_MyObject_amdAdd cb, final int x, final int y, Ice.Current current) { + final boolean retry = current.ctx.get("retry") != null && current.ctx.get("retry").equals("yes"); Thread thread = new Thread() { @Override @@ -78,7 +79,17 @@ class MyObjectI extends _MyObjectDisp catch(InterruptedException e) { } - cb.ice_response(x + y); + try + { + cb.ice_response(x + y); + } + catch(Ice.ResponseSentException ex) + { + if(!retry) + { + throw ex; + } + } } }; 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 c4843c606b4..376c72a76af 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 @@ -977,7 +977,7 @@ public class AllTests out.flush(); props.put("IceMX.Metrics.View.Map.Invocation.GroupBy", "operation"); - props.put("IceMX.Metrics.View.Map.Invocation.Map.Remote.GroupBy", "localPort"); + props.put("IceMX.Metrics.View.Map.Invocation.Map.Remote.GroupBy", "id"); props.put("IceMX.Metrics.View.Map.Invocation.Map.Collocated.GroupBy", "id"); updateProps(clientProps, serverProps, update, props, "Invocation"); test(serverMetrics.getMetricsView("View", timestamp).get("Invocation").length == 0); @@ -1142,13 +1142,9 @@ public class AllTests if(!collocated) { im1 = (IceMX.InvocationMetrics)map.get("fail"); - test(im1.current <= 1 && im1.total == 3 && im1.failures == 3 && im1.retry == 3 && im1.remotes.length == 6); - test(im1.remotes[0].current == 0 && im1.remotes[0].total == 1 && im1.remotes[0].failures == 1); - test(im1.remotes[1].current == 0 && im1.remotes[1].total == 1 && im1.remotes[1].failures == 1); - test(im1.remotes[2].current == 0 && im1.remotes[2].total == 1 && im1.remotes[2].failures == 1); - test(im1.remotes[3].current == 0 && im1.remotes[3].total == 1 && im1.remotes[3].failures == 1); - test(im1.remotes[4].current == 0 && im1.remotes[4].total == 1 && im1.remotes[4].failures == 1); - test(im1.remotes[5].current == 0 && im1.remotes[5].total == 1 && im1.remotes[5].failures == 1); + test(im1.current <= 1 && im1.total == 3 && im1.failures == 3 && im1.retry == 3 && im1.remotes.length == 1); + rim1 = (IceMX.ChildInvocationMetrics)im1.remotes[0]; + test(rim1.current == 0 && rim1.total == 6 && rim1.failures == 6); checkFailure(clientMetrics, "Invocation", im1.id, "::Ice::ConnectionLostException", 3, out); } 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 e4a57497ee6..8de74f60b51 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 @@ -1386,6 +1386,10 @@ public class AllTests { server.ice_ping(); } + catch(Ice.SecurityException ex) + { + // Expected on systems that disable DSA (EL8) + } catch(Ice.LocalException ex) { ex.printStackTrace(); @@ -1511,7 +1515,7 @@ public class AllTests } catch(Ice.ConnectionLostException ex) { - // Expected on systems that disable DSA + // Expected on systems that disable DSA (EL8) } catch(Ice.LocalException ex) { |