You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/10/30 00:29:26 UTC
[05/50] incubator-tinkerpop git commit: TINKERPOP3-910 Clears the
session channel attribute between requests.
TINKERPOP3-910 Clears the session channel attribute between requests.
If this value (and any other channel attribute) isn't cleared it will hang around until the next request as they are global to the channel. In this case, a first "in-session" request would succeed and put the channel in "session" mode. A future sessionless request would arrive and execute its serialization process in the sessions threads as the channel still had the session state from the previous request. This likely would have been easier to debug if the the onReadWrite stuff had been ThreadLocal as the in-session requests would have been in MANUAL mode and the sessionless request would have yielded a more clear error that the transaction was closed. Instead, because it was AUTO the sessionless request auto-opened the tx.
The tests for this are in the link referenced above. We'll need to merge those tests into this branch at some point to get this all to work together.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/43f64c2a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/43f64c2a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/43f64c2a
Branch: refs/heads/TINKERPOP3-925
Commit: 43f64c2a4aad965343ef87ce5407cb0b79d96714
Parents: 2b83c3d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Oct 23 16:36:37 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Oct 23 16:36:37 2015 -0400
----------------------------------------------------------------------
.../gremlin/server/handler/NioGremlinBinaryRequestDecoder.java | 5 +++++
.../gremlin/server/handler/WsGremlinBinaryRequestDecoder.java | 5 +++++
.../gremlin/server/handler/WsGremlinCloseRequestDecoder.java | 5 +++++
.../gremlin/server/handler/WsGremlinTextRequestDecoder.java | 5 +++++
4 files changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/43f64c2a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/NioGremlinBinaryRequestDecoder.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/NioGremlinBinaryRequestDecoder.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/NioGremlinBinaryRequestDecoder.java
index c6996a4..622a2f7 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/NioGremlinBinaryRequestDecoder.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/NioGremlinBinaryRequestDecoder.java
@@ -60,6 +60,11 @@ public class NioGremlinBinaryRequestDecoder extends ReplayingDecoder<NioGremlinB
final String contentType = contentTypeFrame.toString(CharsetUtil.UTF_8);
final MessageSerializer serializer = select(contentType, Serializers.DEFAULT_REQUEST_SERIALIZER);
+
+ // it's important to re-initialize these channel attributes as they apply globally to the channel. in
+ // other words, the next request to this channel might not come with the same configuration and mixed
+ // state can carry through from one request to the next
+ channelHandlerContext.channel().attr(StateKey.SESSION).set(null);
channelHandlerContext.channel().attr(StateKey.SERIALIZER).set(serializer);
channelHandlerContext.channel().attr(StateKey.USE_BINARY).set(true);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/43f64c2a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinBinaryRequestDecoder.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinBinaryRequestDecoder.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinBinaryRequestDecoder.java
index 071eb18..773d33d 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinBinaryRequestDecoder.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinBinaryRequestDecoder.java
@@ -67,8 +67,13 @@ public class WsGremlinBinaryRequestDecoder extends MessageToMessageDecoder<Binar
final String contentType = contentTypeBytes.toString(UTF8);
final MessageSerializer serializer = select(contentType, Serializers.DEFAULT_REQUEST_SERIALIZER);
+ // it's important to re-initialize these channel attributes as they apply globally to the channel. in
+ // other words, the next request to this channel might not come with the same configuration and mixed
+ // state can carry through from one request to the next
+ channelHandlerContext.channel().attr(StateKey.SESSION).set(null);
channelHandlerContext.channel().attr(StateKey.SERIALIZER).set(serializer);
channelHandlerContext.channel().attr(StateKey.USE_BINARY).set(true);
+
try {
objects.add(serializer.deserializeRequest(messageBytes.discardReadBytes()));
} catch (SerializationException se) {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/43f64c2a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinCloseRequestDecoder.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinCloseRequestDecoder.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinCloseRequestDecoder.java
index fc6f3cf..44a0906 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinCloseRequestDecoder.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinCloseRequestDecoder.java
@@ -67,8 +67,13 @@ public class WsGremlinCloseRequestDecoder extends MessageToMessageDecoder<CloseW
final String contentType = contentTypeBytes.toString(UTF8);
final MessageSerializer serializer = select(contentType, Serializers.DEFAULT_REQUEST_SERIALIZER);
+ // it's important to re-initialize these channel attributes as they apply globally to the channel. in
+ // other words, the next request to this channel might not come with the same configuration and mixed
+ // state can carry through from one request to the next
+ channelHandlerContext.channel().attr(StateKey.SESSION).set(null);
channelHandlerContext.channel().attr(StateKey.SERIALIZER).set(serializer);
channelHandlerContext.channel().attr(StateKey.USE_BINARY).set(true);
+
try {
objects.add(serializer.deserializeRequest(messageBytes.discardReadBytes()));
} catch (SerializationException se) {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/43f64c2a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinTextRequestDecoder.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinTextRequestDecoder.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinTextRequestDecoder.java
index 9316c1b..5e05bc2 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinTextRequestDecoder.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/WsGremlinTextRequestDecoder.java
@@ -55,8 +55,13 @@ public class WsGremlinTextRequestDecoder extends MessageToMessageDecoder<TextWeb
// the default serializer must be a MessageTextSerializer instance to be compatible with this decoder
final MessageTextSerializer serializer = (MessageTextSerializer) select("application/json", Serializers.DEFAULT_REQUEST_SERIALIZER);
+ // it's important to re-initialize these channel attributes as they apply globally to the channel. in
+ // other words, the next request to this channel might not come with the same configuration and mixed
+ // state can carry through from one request to the next
+ channelHandlerContext.channel().attr(StateKey.SESSION).set(null);
channelHandlerContext.channel().attr(StateKey.SERIALIZER).set(serializer);
channelHandlerContext.channel().attr(StateKey.USE_BINARY).set(false);
+
objects.add(serializer.deserializeRequest(frame.text()));
} catch (SerializationException se) {
objects.add(RequestMessage.INVALID);