Repository: tinkerpop Updated Branches: refs/heads/master 3cd352eeb -> 8c05c19ea
TINKERPOP-1999 Prevented java driver from hanging on disorderly server shutdown We didn't see this before because all tests had assumed an orderly shutdown. In orderly shutdown the server actually manages to send a kill message which the driver respects. In disorderly shutdown, the channel just goes inactive and as described in TINKERPOP-1999 that event was not being handled properly on the driver causing it to hang. I tried to write a test for this but was unable to as I can't figure out how to write an "disorderly shutdown" which basically involves "pulling the plug" on the server. CTR Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3dcabd4f Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3dcabd4f Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3dcabd4f Branch: refs/heads/master Commit: 3dcabd4f1b23fecde28c79a10502ad562d934c8d Parents: b0c836b Author: Stephen Mallette <sp...@genoprime.com> Authored: Thu Jul 12 10:07:04 2018 -0400 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Thu Jul 12 10:07:04 2018 -0400 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + .../java/org/apache/tinkerpop/gremlin/driver/Handler.java | 8 ++++++++ .../gremlin/driver/handler/WebSocketClientHandler.java | 5 ----- 3 files changed, 9 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3dcabd4f/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index ee49c09..a25e7a5 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -23,6 +23,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima [[release-3-2-10]] === TinkerPop 3.2.10 (Release Date: NOT OFFICIALLY RELEASED YET) +* Fixed bug in Java driver where an disorderly shutdown of the server would cause the client to hang. * Added a dotnet template project that should make it easier to get started with Gremlin.Net. * Removed `ThreadInterruptCustomizerProvider` from documentation as a way to timeout. * Added Docker images for Gremlin Console and Gremlin Server. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3dcabd4f/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java ---------------------------------------------------------------------- diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java index 1bd0a3b..a6528b2 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Handler.java @@ -201,6 +201,14 @@ final class Handler { } @Override + public void channelInactive(final ChannelHandlerContext ctx) throws Exception { + // occurs when the server shutsdown in a disorderly fashion, otherwise in an orderly shutdown the server + // should fire off a close message which will properly release the driver. + super.channelInactive(ctx); + throw new IllegalStateException("Connection to server is no longer active"); + } + + @Override protected void channelRead0(final ChannelHandlerContext channelHandlerContext, final ResponseMessage response) throws Exception { try { final ResponseStatusCode statusCode = response.getStatus().getCode(); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3dcabd4f/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/WebSocketClientHandler.java ---------------------------------------------------------------------- diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/WebSocketClientHandler.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/WebSocketClientHandler.java index 0a1f2f7..7b5858b 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/WebSocketClientHandler.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/WebSocketClientHandler.java @@ -62,11 +62,6 @@ public final class WebSocketClientHandler extends SimpleChannelInboundHandler<Ob } @Override - public void channelInactive(final ChannelHandlerContext ctx) throws Exception { - //System.out.println("WebSocket Client disconnected!"); - } - - @Override protected void channelRead0(final ChannelHandlerContext ctx, final Object msg) throws Exception { final Channel ch = ctx.channel(); if (!handshaker.isHandshakeComplete()) {