tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject tinkerpop git commit: TINKERPOP-1530 Consistent use of instance()
Date Sat, 12 Nov 2016 13:14:23 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1530 [created] 185670fa6


TINKERPOP-1530 Consistent use of instance()

Deprecated getInstance() usage in favor of instance(). This is a non-breaking change for 3.2.0.


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

Branch: refs/heads/TINKERPOP-1530
Commit: 185670fa6165d83458326a6b9d80c124966b7402
Parents: 7c9b47f
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Sat Nov 12 08:13:22 2016 -0500
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Sat Nov 12 08:13:22 2016 -0500

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/dev/io/graphson.asciidoc               |  4 +-
 .../upgrade/release-3.2.x-incubating.asciidoc   | 10 +++
 .../archetype-resources/src/main/java/App.java  |  2 +-
 .../src/main/java/Service.java                  |  2 +-
 .../src/test/java/ServiceTest.java              |  2 +-
 .../SingleGremlinScriptEngineManager.java       |  7 ++
 .../gremlin/structure/io/IoRegistry.java        |  2 +-
 .../gremlin/structure/io/gryo/GryoPool.java     | 23 ++++-
 .../gremlin/structure/io/IoXIoRegistry.java     |  2 +-
 .../gremlin/structure/io/IoYIoRegistry.java     |  2 +-
 .../structure/io/gryo/GryoMapperTest.java       | 12 +--
 .../ser/AbstractGryoMessageSerializerV1d0.java  |  4 +-
 .../driver/ser/AbstractMessageSerializer.java   | 26 +++++-
 .../ser/GryoBaseMessageSerializerV1d0Test.java  | 93 ++++++++++++++++++++
 .../tinkergraph/structure/TinkerGraph.java      |  2 +-
 .../tinkergraph/structure/TinkerIoRegistry.java |  8 ++
 .../structure/TinkerIoRegistryV2d0.java         |  8 ++
 .../TinkerGraphGraphSONSerializerV2d0Test.java  |  4 +-
 .../tinkergraph/structure/TinkerGraphTest.java  |  2 +-
 20 files changed, 191 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index ccbbc89..b0fe5b4 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -47,6 +47,7 @@ TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
 * Added `ProjectStep.getProjectKeys()` for strategies that rely on such information.
 * Added `VertexFeatures.supportsDuplicateMultiProperties()` for graphs that only support
unique values in multi-properties.
 * Deprecated the "performance" tests in `OptIn`.
+* Deprecated `getInstance()` methods in favor of `instance()` for better consistency with
the rest of the API.
 * Block calls to "remote" traversal side-effects until the traversal read is complete which
signifies an end to iteration.
 * Added `Pick.none` and `Pick.any` to the serializers and importers.
 * Added a class loader to `TraversalStrategies.GlobalCache` which guarantees strategies are
registered prior to `GlobalCache.getStrategies()`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/docs/src/dev/io/graphson.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/io/graphson.asciidoc b/docs/src/dev/io/graphson.asciidoc
index 5858b95..cdc9880 100644
--- a/docs/src/dev/io/graphson.asciidoc
+++ b/docs/src/dev/io/graphson.asciidoc
@@ -19,7 +19,7 @@ limitations under the License.
 *******************************************************************************
 import java.time.*
 mapper = GraphSONMapper.build().
-                        addRegistry(TinkerIoRegistry.getInstance()).
+                        addRegistry(TinkerIoRegistry.instance()).
                         addCustomModule(new org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0.GremlinServerModule()).
                         version(GraphSONVersion.V1_0).create().createMapper()
 graph = TinkerFactory.createTheCrew()
@@ -105,7 +105,7 @@ file.withWriter { writer ->
 }
 
 mapper = GraphSONMapper.build().
-                        addRegistry(TinkerIoRegistryV2d0.getInstance()).
+                        addRegistry(TinkerIoRegistryV2d0.instance()).
                         typeInfo(TypeInfo.PARTIAL_TYPES).
                         addCustomModule(GraphSONXModuleV2d0.build().create(false)).
                         addCustomModule(new org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV2d0.GremlinServerModule()).

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 8574b88..dd54dfb 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -80,6 +80,16 @@ following fields were deprecated:
 * `OptIn.SUITE_PROCESS_PERFORMANCE`
 * `OptIn.SUITE_STRUCTURE_PERFORMANCE`
 
+Deprecated getInstance()
+++++++++++++++++++++++++
+
+TinkerPop has generally preferred static `instance()` methods over `getInstance()`, but `getInstance()`
was used in
+some cases nonetheless. As of this release, `getInstance()` methods have been deprecated
in favor of `instance()`.
+Of specific note, custom `IoRegistry` (as related to IO in general) and `Supplier<ClassResolver>`
(as related to
+Gryo serialization in general) now both prefer `instance()` over `getInstance()` given this
deprecation.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1530[TINKERPOP-1530]
+
 Drivers Providers
 ^^^^^^^^^^^^^^^^^
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/main/java/App.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/main/java/App.java
b/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/main/java/App.java
index 1e111e3..506fa6d 100644
--- a/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/main/java/App.java
+++ b/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/main/java/App.java
@@ -26,7 +26,7 @@ public class App {
     private static final Logger logger = LoggerFactory.getLogger(App.class);
 
     public static void main(String[] args) throws Exception {
-        Service service = Service.getInstance();
+        Service service = Service.instance();
         try {
             logger.info("Sending request....");
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/main/java/Service.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/main/java/Service.java
b/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/main/java/Service.java
index b2e9de6..0074daf 100644
--- a/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/main/java/Service.java
+++ b/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/main/java/Service.java
@@ -49,7 +49,7 @@ public class Service implements AutoCloseable {
 
     private Service() {}
 
-    public static Service getInstance() {
+    public static Service instance() {
         return INSTANCE;
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/test/java/ServiceTest.java
----------------------------------------------------------------------
diff --git a/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/test/java/ServiceTest.java
b/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/test/java/ServiceTest.java
index 6f7d5c3..cfac74b 100644
--- a/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/test/java/ServiceTest.java
+++ b/gremlin-archetype/gremlin-archetype-server/src/main/resources/archetype-resources/src/test/java/ServiceTest.java
@@ -42,7 +42,7 @@ import static org.hamcrest.CoreMatchers.is;
 public class ServiceTest {
     private GremlinServer server;
 
-    private static Service service = Service.getInstance();
+    private static Service service = Service.instance();
 
     @Before
     public void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/SingleGremlinScriptEngineManager.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/SingleGremlinScriptEngineManager.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/SingleGremlinScriptEngineManager.java
index e18ec37..9474368 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/SingleGremlinScriptEngineManager.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/SingleGremlinScriptEngineManager.java
@@ -28,7 +28,14 @@ public class SingleGremlinScriptEngineManager {
 
     private SingleGremlinScriptEngineManager() {}
 
+    /**
+     * @deprecated As of release 3.2.4, replaced by {@link #instance()}.
+     */
     public static GremlinScriptEngineManager getInstance(){
+        return instance();
+    }
+
+    public static GremlinScriptEngineManager instance(){
         return cached;
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoRegistry.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoRegistry.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoRegistry.java
index a70e406..78cb3c5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoRegistry.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoRegistry.java
@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
  * A generalized custom serializer registry for providers implementing a {@link Graph}. 
Providers should develop an
  * implementation of this interface if their implementation requires custom serialization
of identifiers or other
  * such content housed in their graph.  Consider extending from {@link AbstractIoRegistry}
and ensure that the
- * implementation has a zero-arg constructor or a static "getInstance" method that returns
an {@code IoRegistry}
+ * implementation has a zero-arg constructor or a static "instance" method that returns an
{@code IoRegistry}
  * instance, as implementations may need to be constructed from reflection given different
parts of the TinkerPop
  * stack.
  * <p/>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoPool.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoPool.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoPool.java
index 59f8a5d..80bf45d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoPool.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoPool.java
@@ -228,13 +228,13 @@ public final class GryoPool {
                     final String className = c.toString();
                     final Class<?> clazz = Class.forName(className);
                     try {
-                        final Method instanceMethod = clazz.getDeclaredMethod("getInstance");
+                        final Method instanceMethod = tryInstanceMethod(clazz);
                         if (IoRegistry.class.isAssignableFrom(instanceMethod.getReturnType()))
                             registries.add((IoRegistry) instanceMethod.invoke(null));
                         else
                             throw new Exception();
                     } catch (Exception methodex) {
-                        // tried getInstance() and that failed so try newInstance() no-arg
constructor
+                        // tried instance() and that failed so try newInstance() no-arg constructor
                         registries.add((IoRegistry) clazz.newInstance());
                     }
                 } catch (Exception ex) {
@@ -243,5 +243,24 @@ public final class GryoPool {
             });
             return registries;
         }
+
+        private static Method tryInstanceMethod(final Class clazz) {
+            Method instanceMethod;
+            try {
+                instanceMethod = clazz.getDeclaredMethod("instance");
+            } catch (Exception methodex) {
+                instanceMethod = null;
+            }
+
+            if (null == instanceMethod) {
+                try {
+                    instanceMethod = clazz.getDeclaredMethod("getInstance");
+                } catch (Exception methodex) {
+                    instanceMethod = null;
+                }
+            }
+
+            return instanceMethod;
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/IoXIoRegistry.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/IoXIoRegistry.java
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/IoXIoRegistry.java
index c49ea0b..21cc5d5 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/IoXIoRegistry.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/IoXIoRegistry.java
@@ -51,7 +51,7 @@ public class IoXIoRegistry {
             register(GryoIo.class, IoX.class, null);
         }
 
-        public static InstanceBased getInstance() {
+        public static InstanceBased instance() {
             return INSTANCE;
         }
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/IoYIoRegistry.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/IoYIoRegistry.java
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/IoYIoRegistry.java
index 1654945..738fff5 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/IoYIoRegistry.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/IoYIoRegistry.java
@@ -46,7 +46,7 @@ public class IoYIoRegistry {
             register(GryoIo.class, IoY.class, null);
         }
 
-        public static InstanceBased getInstance() {
+        public static InstanceBased instance() {
             return INSTANCE;
         }
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
index 29b2da9..6f808e4 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
@@ -174,8 +174,8 @@ public class GryoMapperTest {
     @Test
     public void shouldRegisterMultipleIoRegistryToSerialize() throws Exception {
         final GryoMapper mapper = GryoMapper.build()
-                .addRegistry(IoXIoRegistry.InstanceBased.getInstance())
-                .addRegistry(IoYIoRegistry.InstanceBased.getInstance()).create();
+                .addRegistry(IoXIoRegistry.InstanceBased.instance())
+                .addRegistry(IoYIoRegistry.InstanceBased.instance()).create();
         final Kryo kryo = mapper.createMapper();
         try (final OutputStream stream = new ByteArrayOutputStream()) {
             final Output out = new Output(stream);
@@ -197,12 +197,12 @@ public class GryoMapperTest {
     @Test
     public void shouldExpectReadFailureAsIoRegistryOrderIsNotRespected() throws Exception
{
         final GryoMapper mapperWrite = GryoMapper.build()
-                .addRegistry(IoXIoRegistry.InstanceBased.getInstance())
-                .addRegistry(IoYIoRegistry.InstanceBased.getInstance()).create();
+                .addRegistry(IoXIoRegistry.InstanceBased.instance())
+                .addRegistry(IoYIoRegistry.InstanceBased.instance()).create();
 
         final GryoMapper mapperRead = GryoMapper.build()
-                .addRegistry(IoYIoRegistry.InstanceBased.getInstance())
-                .addRegistry(IoXIoRegistry.InstanceBased.getInstance()).create();
+                .addRegistry(IoYIoRegistry.InstanceBased.instance())
+                .addRegistry(IoXIoRegistry.InstanceBased.instance()).create();
 
         final Kryo kryoWriter = mapperWrite.createMapper();
         final Kryo kryoReader = mapperRead.createMapper();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
index 498536d..ace6bb0 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
@@ -124,10 +124,10 @@ public abstract class AbstractGryoMessageSerializerV1d0 extends AbstractMessageS
             try {
                 final Class<?> clazz = Class.forName(className);
                 try {
-                    final Method instanceMethod = clazz.getDeclaredMethod("getInstance");
+                    final Method instanceMethod = tryInstanceMethod(clazz);
                     builder.classResolver((Supplier<ClassResolver>) instanceMethod.invoke(null));
                 } catch (Exception methodex) {
-                    // tried getInstance() and that failed so try newInstance() no-arg constructor
+                    // tried instance() and that failed so try newInstance() no-arg constructor
                     builder.classResolver((Supplier<ClassResolver>) clazz.newInstance());
                 }
             } catch (Exception ex) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractMessageSerializer.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractMessageSerializer.java
b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractMessageSerializer.java
index 3c4380c..59937c3 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractMessageSerializer.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractMessageSerializer.java
@@ -40,7 +40,7 @@ public abstract class AbstractMessageSerializer implements MessageSerializer
{
      * Reads a list of fully qualified class names from the value of the {@link #TOKEN_IO_REGISTRIES}
configuration
      * key. These classes should equate to {@link IoRegistry} implementations that will be
assigned to the
      * {@link org.apache.tinkerpop.gremlin.structure.io.Mapper.Builder}.  The assumption
is that the
-     * {@link IoRegistry} either has a static {@code getInstance()} method or has a zero-arg
constructor from which
+     * {@link IoRegistry} either has a static {@code instance()} method or has a zero-arg
constructor from which
      * it can be instantiated.
      */
     protected void addIoRegistries(final Map<String, Object> config, final Mapper.Builder
builder) {
@@ -50,13 +50,14 @@ public abstract class AbstractMessageSerializer implements MessageSerializer
{
             try {
                 final Class<?> clazz = Class.forName(className);
                 try {
-                    final Method instanceMethod = clazz.getDeclaredMethod("getInstance");
+                    // try instance() first and then instance() which was deprecated in 3.2.4
+                    final Method instanceMethod = tryInstanceMethod(clazz);
                     if (IoRegistry.class.isAssignableFrom(instanceMethod.getReturnType()))
                         builder.addRegistry((IoRegistry) instanceMethod.invoke(null));
                     else
                         throw new Exception();
                 } catch (Exception methodex) {
-                    // tried getInstance() and that failed so try newInstance() no-arg constructor
+                    // tried instance() and that failed so try newInstance() no-arg constructor
                     builder.addRegistry((IoRegistry) clazz.newInstance());
                 }
             } catch (Exception ex) {
@@ -65,6 +66,25 @@ public abstract class AbstractMessageSerializer implements MessageSerializer
{
         });
     }
 
+    protected Method tryInstanceMethod(final Class clazz) {
+        Method instanceMethod;
+        try {
+            instanceMethod = clazz.getDeclaredMethod("instance");
+        } catch (Exception methodex) {
+            instanceMethod = null;
+        }
+
+        if (null == instanceMethod) {
+            try {
+                instanceMethod = clazz.getDeclaredMethod("getInstance");
+            } catch (Exception methodex) {
+                instanceMethod = null;
+            }
+        }
+
+        return instanceMethod;
+    }
+
     /**
      * Gets a {@link List} of strings from the configuration object.
      */

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java
b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java
index 99bd564..4a63d65 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java
@@ -116,6 +116,40 @@ public class GryoBaseMessageSerializerV1d0Test {
     }
 
     @Test
+    public void shouldConfigureIoRegistryInstance() throws Exception {
+        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
+        final Map<String, Object> config = new HashMap<String, Object>() {{
+            put(GryoMessageSerializerV1d0.TOKEN_IO_REGISTRIES, Arrays.asList(ColorIoRegistryInstance.class.getName()));
+        }};
+
+        serializer.configure(config, null);
+
+        final ResponseMessage toSerialize = ResponseMessage.build(requestId).result(Color.RED).create();
+        final ByteBuf bb = serializer.serializeResponseAsBinary(toSerialize, allocator);
+        final ResponseMessage deserialized = serializer.deserializeResponse(bb);
+
+        assertCommon(deserialized);
+        assertEquals(Color.RED, deserialized.getResult().getData());
+    }
+
+    @Test
+    public void shouldConfigureIoRegistryGetInstance() throws Exception {
+        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
+        final Map<String, Object> config = new HashMap<String, Object>() {{
+            put(GryoMessageSerializerV1d0.TOKEN_IO_REGISTRIES, Arrays.asList(ColorIoRegistryGetInstance.class.getName()));
+        }};
+
+        serializer.configure(config, null);
+
+        final ResponseMessage toSerialize = ResponseMessage.build(requestId).result(Color.RED).create();
+        final ByteBuf bb = serializer.serializeResponseAsBinary(toSerialize, allocator);
+        final ResponseMessage deserialized = serializer.deserializeResponse(bb);
+
+        assertCommon(deserialized);
+        assertEquals(Color.RED, deserialized.getResult().getData());
+    }
+
+    @Test
     public void shouldConfigureCustomClassResolver() {
         final MessageSerializer serializer = new GryoMessageSerializerV1d0();
         final Map<String, Object> config = new HashMap<String, Object>() {{
@@ -150,6 +184,23 @@ public class GryoBaseMessageSerializerV1d0Test {
     }
 
     @Test
+    public void shouldConfigureCustomClassResolverFromGetInstance() {
+        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
+        final Map<String, Object> config = new HashMap<String, Object>() {{
+            put(GryoMessageSerializerV1d0.TOKEN_CLASS_RESOLVER_SUPPLIER, ErrorOnlyClassResolverSupplierAsGetInstance.class.getName());
+        }};
+
+        serializer.configure(config, null);
+
+        try {
+            serializer.serializeResponseAsBinary(responseMessageBuilder.create(), allocator);
+            fail("Should fail because the ClassResolver used here always generates an error");
+        } catch (Exception ex) {
+            assertEquals("java.lang.RuntimeException: Registration is not allowed with this
ClassResolver - it is not a good implementation", ex.getMessage());
+        }
+    }
+
+    @Test
     public void shouldSerializeIterable() throws Exception {
         final ArrayList<Integer> list = new ArrayList<>();
         list.add(1);
@@ -476,6 +527,22 @@ public class GryoBaseMessageSerializerV1d0Test {
 
         private ErrorOnlyClassResolverSupplierAsInstance() {}
 
+        public static ErrorOnlyClassResolverSupplierAsInstance instance() {
+            return instance;
+        }
+
+        @Override
+        public ClassResolver get() {
+            return new ErrorOnlyClassResolver();
+        }
+    }
+
+    public static class ErrorOnlyClassResolverSupplierAsGetInstance implements Supplier<ClassResolver>
{
+
+        private static final ErrorOnlyClassResolverSupplierAsInstance instance = new ErrorOnlyClassResolverSupplierAsInstance();
+
+        private ErrorOnlyClassResolverSupplierAsGetInstance() {}
+
         public static ErrorOnlyClassResolverSupplierAsInstance getInstance() {
             return instance;
         }
@@ -506,6 +573,32 @@ public class GryoBaseMessageSerializerV1d0Test {
         }
     }
 
+    public static class ColorIoRegistryInstance extends AbstractIoRegistry {
+
+        private static final ColorIoRegistry instance = new ColorIoRegistry();
+
+        private ColorIoRegistryInstance() {
+            register(GryoIo.class, Color.class, new ColorSerializer());
+        }
+
+        public static ColorIoRegistry instance() {
+            return instance;
+        }
+    }
+
+    public static class ColorIoRegistryGetInstance extends AbstractIoRegistry {
+
+        private static final ColorIoRegistry instance = new ColorIoRegistry();
+
+        private ColorIoRegistryGetInstance() {
+            register(GryoIo.class, Color.class, new ColorSerializer());
+        }
+
+        public static ColorIoRegistry getInstance() {
+            return instance;
+        }
+    }
+
     public static class ColorSerializer extends Serializer<Color> {
         @Override
         public void write(final Kryo kryo, final Output output, final Color color) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
index e498b30..48f4d3d 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
@@ -233,7 +233,7 @@ public final class TinkerGraph implements Graph {
 
     @Override
     public <I extends Io> I io(final Io.Builder<I> builder) {
-        return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistry.getInstance())).create();
+        return (I) builder.graph(this).onMapper(mapper -> mapper.addRegistry(TinkerIoRegistry.instance())).create();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
index 3c9cdd0..64398c9 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistry.java
@@ -78,7 +78,15 @@ public final class TinkerIoRegistry extends AbstractIoRegistry {
         register(GraphSONIo.class, null, new TinkerModule());
     }
 
+    /**
+     * @deprecated As of release 3.2.4, replaced by {@link #instance()}.
+     */
+    @Deprecated
     public static TinkerIoRegistry getInstance() {
+        return instance();
+    }
+
+    public static TinkerIoRegistry instance() {
         return INSTANCE;
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
index 0681ff1..83ee26f 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
@@ -74,10 +74,18 @@ public final class TinkerIoRegistryV2d0 extends AbstractIoRegistry {
         register(GraphSONIo.class, null, new TinkerModuleV2d0());
     }
 
+    /**
+     * @deprecated As of release 3.2.4, replaced by {@link #instance()}.
+     */
+    @Deprecated
     public static TinkerIoRegistryV2d0 getInstance() {
         return INSTANCE;
     }
 
+    public static TinkerIoRegistryV2d0 instance() {
+        return INSTANCE;
+    }
+
     /**
      * Provides a method to serialize an entire {@link org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph}
into itself for Gryo.  This is useful when
      * shipping small graphs around through Gremlin Server. Reuses the existing Kryo instance
for serialization.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGraphSONSerializerV2d0Test.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGraphSONSerializerV2d0Test.java
b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGraphSONSerializerV2d0Test.java
index 6d39838..3b09026 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGraphSONSerializerV2d0Test.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGraphSONSerializerV2d0Test.java
@@ -65,14 +65,14 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
     private final Mapper defaultMapperV2d0 = GraphSONMapper.build()
             .version(GraphSONVersion.V2_0)
             .addCustomModule(GraphSONXModuleV2d0.build().create(false))
-            .addRegistry(TinkerIoRegistryV2d0.getInstance())
+            .addRegistry(TinkerIoRegistryV2d0.instance())
             .create();
 
     private final Mapper noTypesMapperV2d0 = GraphSONMapper.build()
             .version(GraphSONVersion.V2_0)
             .addCustomModule(GraphSONXModuleV2d0.build().create(false))
             .typeInfo(TypeInfo.NO_TYPES)
-            .addRegistry(TinkerIoRegistryV2d0.getInstance())
+            .addRegistry(TinkerIoRegistryV2d0.instance())
             .create();
 
     /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/185670fa/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index 1baf6af..451bc3b 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -521,7 +521,7 @@ public class TinkerGraphTest {
         final ArrayList<Color> colorList = new ArrayList<>(Arrays.asList(Color.RED,
Color.GREEN));
 
         final Supplier<ClassResolver> classResolver = new CustomClassResolverSupplier();
-        final GryoMapper mapper = GryoMapper.build().addRegistry(TinkerIoRegistry.getInstance()).classResolver(classResolver).create();
+        final GryoMapper mapper = GryoMapper.build().addRegistry(TinkerIoRegistry.instance()).classResolver(classResolver).create();
         final Kryo kryo = mapper.createMapper();
         try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
             final Output out = new Output(stream);


Mime
View raw message