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 2015/05/15 13:44:21 UTC

[1/2] incubator-tinkerpop git commit: Finalize GraphSONUtil class - just a utility class with static methods.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master f7ee04a73 -> d1f5f8603


Finalize GraphSONUtil class - just a utility class with static methods.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/cb4ecf5e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/cb4ecf5e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/cb4ecf5e

Branch: refs/heads/master
Commit: cb4ecf5e7c05661541f98917e1b87e27a18b557d
Parents: f7ee04a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 15 07:07:19 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 15 07:07:19 2015 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/cb4ecf5e/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
index 8e5a69b..6ba28d8 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
@@ -30,7 +30,7 @@ import java.io.IOException;
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public class GraphSONUtil {
+public final class GraphSONUtil {
     public static void writeWithType(final String key, final Object object, final JsonGenerator jsonGenerator,
                                      final SerializerProvider serializerProvider,
                                      final TypeSerializer typeSerializer) throws IOException {


[2/2] incubator-tinkerpop git commit: Prevent the default jackson serialization from taking over when types aren't embedded.

Posted by sp...@apache.org.
Prevent the default jackson serialization from taking over when types aren't embedded.

If a graph has a custom serializer and types are not embedded that serializer should still be used if present as it likely has a better and more compact representation than what the standard jackson serializer will do.  Furthermore the default serializer may try to serialize fields that throw exceptions thus halting the serialization process.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/d1f5f860
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/d1f5f860
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/d1f5f860

Branch: refs/heads/master
Commit: d1f5f8603c60f584b7a514280980d3957e451e69
Parents: cb4ecf5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 15 07:42:27 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 15 07:42:27 2015 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java  | 6 +++++-
 .../apache/tinkerpop/gremlin/structure/SerializationTest.java  | 3 ---
 2 files changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d1f5f860/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
index 6ba28d8..cee7611 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
@@ -36,10 +36,14 @@ public final class GraphSONUtil {
                                      final TypeSerializer typeSerializer) throws IOException {
         final JsonSerializer<Object> serializer = serializerProvider.findValueSerializer(object.getClass(), null);
         if (typeSerializer != null) {
+            // serialize with types embedded
             jsonGenerator.writeFieldName(key);
             serializer.serializeWithType(object, jsonGenerator, serializerProvider, typeSerializer);
         } else {
-            jsonGenerator.writeObjectField(key, object);
+            // types are not embedded, but use the serializer when possible or else custom serializers will get
+            // bypassed and you end up with the default jackson serializer when you don't want it.
+            jsonGenerator.writeFieldName(key);
+            serializer.serialize(object, jsonGenerator, serializerProvider);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d1f5f860/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
index 7e401bc..8ef70b1 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/SerializationTest.java
@@ -24,13 +24,11 @@ import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.process.traversal.Path;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics;
-import org.apache.tinkerpop.gremlin.structure.io.IoTest;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
-import org.apache.tinkerpop.gremlin.structure.util.Comparators;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
@@ -45,7 +43,6 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;