You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/09/23 17:00:03 UTC
[1/2] tinkerpop git commit: Fixed SerializerProvider for GraphSON 2.0.
Repository: tinkerpop
Updated Branches:
refs/heads/master 8eefb7062 -> b8530f702
Fixed SerializerProvider for GraphSON 2.0.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5060dce4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5060dce4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5060dce4
Branch: refs/heads/master
Commit: 5060dce47be41afb97669c86d0829a249292ef71
Parents: ec76c26
Author: Kevin Gallardo <ke...@datastax.com>
Authored: Thu Sep 22 11:56:20 2016 +0100
Committer: Kevin Gallardo <ke...@datastax.com>
Committed: Thu Sep 22 11:57:50 2016 +0100
----------------------------------------------------------------------
.../io/graphson/GraphSONSerializerProvider.java | 12 +++++++---
.../ser/GraphSONMessageSerializerV2d0Test.java | 24 ++++++++++++++++++++
2 files changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5060dce4/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializerProvider.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializerProvider.java
index c373692..60c3200 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializerProvider.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializerProvider.java
@@ -33,7 +33,7 @@ import org.apache.tinkerpop.shaded.jackson.databind.ser.std.ToStringSerializer;
*/
final class GraphSONSerializerProvider extends DefaultSerializerProvider {
private static final long serialVersionUID = 1L;
- private static JsonSerializer<Object> unknownTypeSerializer = new ToStringSerializer();
+ private final JsonSerializer<Object> unknownTypeSerializer;
public GraphSONSerializerProvider(GraphSONVersion version) {
super();
@@ -47,8 +47,10 @@ final class GraphSONSerializerProvider extends DefaultSerializerProvider {
}
protected GraphSONSerializerProvider(final SerializerProvider src,
- final SerializationConfig config, final SerializerFactory f) {
+ final SerializationConfig config, final SerializerFactory f,
+ final JsonSerializer<Object> unknownTypeSerializer) {
super(src, config, f);
+ this.unknownTypeSerializer = unknownTypeSerializer;
}
@Override
@@ -59,6 +61,10 @@ final class GraphSONSerializerProvider extends DefaultSerializerProvider {
@Override
public GraphSONSerializerProvider createInstance(final SerializationConfig config,
final SerializerFactory jsf) {
- return new GraphSONSerializerProvider(this, config, jsf);
+ // createInstance is called pretty often to create a new SerializerProvider
+ // we give it the unknownTypeSerializer that we had in the first place,
+ // when the object was first constructed through the public constructor
+ // that has a GraphSONVersion.
+ return new GraphSONSerializerProvider(this, config, jsf, unknownTypeSerializer);
}
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5060dce4/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV2d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV2d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV2d0Test.java
index de9b493..d3dbecc 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV2d0Test.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV2d0Test.java
@@ -29,8 +29,12 @@ import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry;
+import org.apache.tinkerpop.gremlin.structure.io.GraphWriter;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
@@ -46,6 +50,7 @@ import org.apache.tinkerpop.shaded.jackson.databind.util.StdDateFormat;
import org.junit.Test;
import java.awt.Color;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -467,6 +472,25 @@ public class GraphSONMessageSerializerV2d0Test {
.get(GraphSONTokens.VALUE).asText());
}
+ @Test
+ public void shouldToStringUnknownObjects() {
+ GraphSONMapper gm20 = GraphSONMapper.build().version(GraphSONVersion.V2_0).create();
+ GraphSONMapper gm10 = GraphSONMapper.build().version(GraphSONVersion.V1_0).create();
+
+ GraphWriter writer = GraphSONWriter.build().mapper(gm20).create();
+ // subsequent creations of GraphWriters and GraphSONMappers should not affect
+ // each other.
+ GraphWriter writer2 = GraphSONWriter.build().mapper(gm10).create();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ writer.writeObject(baos, new FunObject("value"));
+ assertEquals(baos.toString(), "\"value\"");
+ } catch (Exception e) {
+ fail("should have succeeded serializing the unknown object to a string");
+ }
+ }
+
private class FunObject {
private String val;
[2/2] tinkerpop git commit: Merge branch 'pr-432'
Posted by sp...@apache.org.
Merge branch 'pr-432'
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b8530f70
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b8530f70
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b8530f70
Branch: refs/heads/master
Commit: b8530f7029b8a14d1b0cfdde191acd6295356052
Parents: 8eefb70 5060dce
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Sep 23 12:13:25 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Sep 23 12:13:25 2016 -0400
----------------------------------------------------------------------
.../io/graphson/GraphSONSerializerProvider.java | 12 +++++++---
.../ser/GraphSONMessageSerializerV2d0Test.java | 24 ++++++++++++++++++++
2 files changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------