Repository: avro Updated Branches: refs/heads/master 230c7e753 -> 52d12bbc1
AVRO-1973: Upgrade netty to the latest 3.x release Upgrading netty version to 3.10.6 caused a test failure. The root cause was that from 3.6.0 netty does not interrupt worker threads therefore, server2.close() would hang until blockingSimpleImpl.releaseRunPermit() is invoked. Could not find any way to call an interrupt on the related workers therefore, modified the test. Signed-off-by: Ben McCann <[email protected]> Signed-off-by: Sean Busbey <[email protected]> Closes #178 Project: http://git-wip-us.apache.org/repos/asf/avro/repo Commit: http://git-wip-us.apache.org/repos/asf/avro/commit/52d12bbc Tree: http://git-wip-us.apache.org/repos/asf/avro/tree/52d12bbc Diff: http://git-wip-us.apache.org/repos/asf/avro/diff/52d12bbc Branch: refs/heads/master Commit: 52d12bbc11a2990d5c4b49fd7a971341f4474922 Parents: 230c7e7 Author: Gabor Szadovszky <[email protected]> Authored: Mon Feb 20 09:01:25 2017 +0100 Committer: Gabor Szadovszky <[email protected]> Committed: Mon Feb 20 09:01:25 2017 +0100 ---------------------------------------------------------------------- .../avro/ipc/TestNettyServerWithCallbacks.java | 35 ++++++++++++-------- lang/java/pom.xml | 2 +- 2 files changed, 23 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/avro/blob/52d12bbc/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java ---------------------------------------------------------------------- diff --git a/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java b/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java index 3a9e158..6ed898a 100644 --- a/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java +++ b/lang/java/ipc/src/test/java/org/apache/avro/ipc/TestNettyServerWithCallbacks.java @@ -25,6 +25,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -370,8 +371,8 @@ public class TestNettyServerWithCallbacks { } } - @Test - public void cancelPendingRequestsAfterChannelCloseByServerShutdown() throws Exception { + @Test(timeout = 20000) + public void cancelPendingRequestsAfterChannelCloseByServerShutdown() throws Throwable { // The purpose of this test is to verify that a client doesn't stay // blocked when a server is unexpectedly killed (or when for some // other reason the channel is suddenly closed) while the server @@ -381,7 +382,7 @@ public class TestNettyServerWithCallbacks { // Start up a second server so that closing the server doesn't // interfere with the other unit tests: BlockingSimpleImpl blockingSimpleImpl = new BlockingSimpleImpl(); - Server server2 = new NettyServer(new SpecificResponder(Simple.class, + final Server server2 = new NettyServer(new SpecificResponder(Simple.class, blockingSimpleImpl), new InetSocketAddress(0)); server2.start(); @@ -404,7 +405,8 @@ public class TestNettyServerWithCallbacks { // Acquire the run permit, to avoid that the server method returns immediately blockingSimpleImpl.acquireRunPermit(); - Thread t = new Thread(new Runnable() { + // Start client call + Future<?> clientFuture = Executors.newSingleThreadExecutor().submit(new Runnable() { @Override public void run() { try { @@ -416,23 +418,30 @@ public class TestNettyServerWithCallbacks { } }); - // Start client call - t.start(); - // Wait until method is entered on the server side blockingSimpleImpl.acquireEnterPermit(); // The server side method is now blocked waiting on the run permit // (= is busy handling the request) - // Stop the server - server2.close(); + // Stop the server in a separate thread as it blocks the actual thread until the server side + // method is running + new Thread(new Runnable() { + @Override + public void run() { + server2.close(); + } + }).start(); // With the server gone, we expect the client to get some exception and exit - // Wait for client thread to exit - t.join(10000); - - Assert.assertFalse("Client request should not be blocked on server shutdown", t.isAlive()); + // Wait for the client call to exit + try { + clientFuture.get(10, TimeUnit.SECONDS); + } catch (ExecutionException e) { + throw e.getCause(); + } catch (TimeoutException e) { + Assert.fail("Client request should not be blocked on server shutdown"); + } } finally { blockingSimpleImpl.releaseRunPermit(); http://git-wip-us.apache.org/repos/asf/avro/blob/52d12bbc/lang/java/pom.xml ---------------------------------------------------------------------- diff --git a/lang/java/pom.xml b/lang/java/pom.xml index 0e753e9..70c8693 100644 --- a/lang/java/pom.xml +++ b/lang/java/pom.xml @@ -49,7 +49,7 @@ <jetty-servlet-api.version>2.5-20081211</jetty-servlet-api.version> <jopt-simple.version>5.0.3</jopt-simple.version> <junit.version>4.12</junit.version> - <netty.version>3.5.13.Final</netty.version> + <netty.version>3.10.6.Final</netty.version> <paranamer.version>2.8</paranamer.version> <protobuf.version>2.6.1</protobuf.version> <thrift.version>0.9.3</thrift.version>
