This is an automated email from the ASF dual-hosted git repository. kenhuuu pushed a commit to branch remove-ser-opt in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 6024a2f0141756f894a128c749ec27352fcd8d4c Author: Ken Hu <[email protected]> AuthorDate: Mon Jun 22 16:27:42 2026 -0700 Rename configuration to responseSerializer. This makes it consistent among all the GLVs and ensures that users know that is for response size deserialization only and not request serialization. Assisted-by: Claude Code:claude-opus-4-8 --- CHANGELOG.asciidoc | 2 ++ docs/src/reference/gremlin-variants.asciidoc | 9 +++--- docs/src/upgrade/release-4.x.x.asciidoc | 1 + gremlin-console/conf/remote-secure.yaml | 2 +- gremlin-console/conf/remote-sigv4.yaml | 2 +- gremlin-console/conf/remote.yaml | 2 +- .../tinkerpop/gremlin/console/jsr223/remote.yaml | 2 +- .../src/main/java/examples/Connections.java | 4 +-- .../apache/tinkerpop/gremlin/driver/Cluster.java | 37 ++++++++++++---------- .../apache/tinkerpop/gremlin/driver/Settings.java | 17 +++++----- .../gremlin/driver/util/ProfilingApplication.java | 2 +- .../driver/ClientBehaviorIntegrateTest.java | 2 +- .../tinkerpop/gremlin/driver/SettingsTest.java | 8 ++--- gremlin-examples/gremlin-java/Connections.java | 4 +-- .../gremlin-javascript/lib/driver/connection.ts | 21 ++++++------ .../test/unit/graphbinary/precise-mode-test.js | 10 +++--- .../test/unit/pdt-registry-test.js | 8 ++--- .../gremlin/driver/remote/RemoteWorld.java | 2 +- .../gremlin/server/GremlinDriverIntegrateTest.java | 16 +++++----- .../server/GremlinResultSetIntegrateTest.java | 2 +- .../GremlinServerSerializationIntegrateTest.java | 2 +- .../src/test/resources/conf/remote-objects.yaml | 2 +- 22 files changed, 83 insertions(+), 74 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index c77c4062b9..1cf6a1bc90 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -67,6 +67,8 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima ** Added a `proxy(ProxyOptions)` builder that inserts a Netty `HttpProxyHandler` into the pipeline before the SSL handler. ** Removed the `maxResponseContentLength` connection option and its `HttpObjectAggregator` cap; responses are streamed and the new `readTimeout` is the partial mitigation. ** Reconciled the `validationRequest` default: the builder default is now `g.inject(0)` to match the `Settings` default (it was previously `''`). +* Renamed the `gremlin-driver` `serializer` configuration to `responseSerializer` to match the other GLVs and to make clear it only controls response deserialization (requests are always sent as JSON). +* Renamed the `gremlin-javascript` `reader` connection option to `responseSerializer` to match the other GLVs and to make clear it only controls response deserialization (requests are always sent as JSON). * Removed `Transaction.open()` in favor of `begin()`, which is now the single transaction-start primitive across embedded and remote contexts. * Changed `begin()` and `close()` to be idempotent and calling it when a transaction is already in that state no longer throws. * Added configurable CORS `allowedOrigins` setting to Gremlin Server; warns when wildcard origin is used alongside authentication. diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc index 941e2e83dd..bd9b52f551 100644 --- a/docs/src/reference/gremlin-variants.asciidoc +++ b/docs/src/reference/gremlin-variants.asciidoc @@ -1086,8 +1086,8 @@ The following table describes the various configuration options for the Gremlin |password |The password to submit on requests that require authentication. |_none_ |path |The URL path to the Gremlin Server. |_/gremlin_ |port |The port of the Gremlin Server to connect to. The same port will be applied for all hosts. |8182 -|serializer.className |The fully qualified class name of the `MessageSerializer` that will be used to deserialize responses from the server. Note that the serializer configured on the client should be supported by the server configuration. |_none_ -|serializer.config |A `Map` of configuration settings for the serializer. |_none_ +|responseSerializer.className |The fully qualified class name of the `MessageSerializer` that will be used to deserialize responses from the server. Note that the serializer configured on the client should be supported by the server configuration. |_none_ +|responseSerializer.config |A `Map` of configuration settings for the serializer. |_none_ |username |The username to submit on requests that require authentication. |_none_ |workerPoolSize |Size of the pool for handling background work. |available processors * 2 |========================================================= @@ -1210,7 +1210,7 @@ IoRegistry registry = ...; // an IoRegistry instance exposed by a specific graph TypeSerializerRegistry typeSerializerRegistry = TypeSerializerRegistry.build().addRegistry(registry).create(); MessageSerializer serializer = new GraphBinaryMessageSerializerV4(typeSerializerRegistry); Cluster cluster = Cluster.build(). - serializer(serializer). + responseSerializer(serializer). create(); Client client = cluster.connect(); GraphTraversalSource g = traversal().with(DriverRemoteConnection.using(client, "g")); @@ -1989,8 +1989,7 @@ can be passed in the constructor of a new `Client` or `DriverRemoteConnection` : |options.interceptors |RequestInterceptor/RequestInterceptor[] |One or more functions that can modify the HTTP request before it is sent. |undefined |options.auth |RequestInterceptor |An auth interceptor that is always appended to the end of the interceptor list so it runs last. |undefined |options.preciseNumbers |Boolean |When `true`, wraps deserialized numbers in typed wrappers that preserve the server's original type. |undefined -|options.reader |GraphBinaryReader |The reader to use for deserializing responses. |GraphBinaryReader -|options.writer |GraphBinaryWriter |The writer to use for serializing requests. |GraphBinaryWriter +|options.responseSerializer |GraphBinaryReader |The reader to use for deserializing responses. |GraphBinaryReader |options.enableUserAgentOnConnect |Boolean |Determines if a user agent header will be sent with requests. |true |options.agent |Agent |A custom `node:http` or `node:https` Agent for connection pooling or proxy configuration. |undefined |options.pdtRegistry |ProviderDefinedTypeRegistry |A registry for hydrating and dehydrating <<gremlin-javascript-pdt,Provider Defined Types>>. |undefined diff --git a/docs/src/upgrade/release-4.x.x.asciidoc b/docs/src/upgrade/release-4.x.x.asciidoc index 0c1a3ca37d..6fb62601a8 100644 --- a/docs/src/upgrade/release-4.x.x.asciidoc +++ b/docs/src/upgrade/release-4.x.x.asciidoc @@ -183,6 +183,7 @@ names: - `idleConnectionTimeoutMillis` is now `idleTimeout` (default 180000 ms), settable as `idleTimeout(Duration)` or `idleTimeoutMillis(long)` (YAML key `connectionPool.idleTimeoutMillis`). - `connectionSetupTimeoutMillis` is now `connectTimeout`, settable as `connectTimeout(Duration)` or `connectTimeoutMillis(int)` (YAML key `connectionPool.connectTimeoutMillis`). - `resultIterationBatchSize` is now `batchSize` (default 64); it sets the connection-level default that fills a request's per-request `batchSize` when unset (mirroring how `bulkResults` shares one name across connection and per-request scopes). +- `serializer` is now `responseSerializer`, to match the other GLVs and to make clear it only controls response deserialization. - A new `ssl(SslContext)` builder accepts a fully configured Netty `SslContext`. - On `RequestOptions`, `addG` is now `traversalSource`. diff --git a/gremlin-console/conf/remote-secure.yaml b/gremlin-console/conf/remote-secure.yaml index 9360315fd9..36021af370 100644 --- a/gremlin-console/conf/remote-secure.yaml +++ b/gremlin-console/conf/remote-secure.yaml @@ -32,4 +32,4 @@ auth: { connectionPool: { enableSsl: true, sslEnabledProtocols: [TLSv1.2] } -serializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4} \ No newline at end of file +responseSerializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4} \ No newline at end of file diff --git a/gremlin-console/conf/remote-sigv4.yaml b/gremlin-console/conf/remote-sigv4.yaml index 0ffc3244b8..ebde10bce0 100644 --- a/gremlin-console/conf/remote-sigv4.yaml +++ b/gremlin-console/conf/remote-sigv4.yaml @@ -28,4 +28,4 @@ auth: { connectionPool: { enableSsl: true, sslEnabledProtocols: [TLSv1.2] } -serializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4} \ No newline at end of file +responseSerializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4} \ No newline at end of file diff --git a/gremlin-console/conf/remote.yaml b/gremlin-console/conf/remote.yaml index 75659d5292..b2255f6bb1 100644 --- a/gremlin-console/conf/remote.yaml +++ b/gremlin-console/conf/remote.yaml @@ -28,4 +28,4 @@ hosts: [localhost] port: 8182 -serializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4} +responseSerializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4} diff --git a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/jsr223/remote.yaml b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/jsr223/remote.yaml index 9a232e3dc6..88249735ba 100644 --- a/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/jsr223/remote.yaml +++ b/gremlin-console/src/test/resources/org/apache/tinkerpop/gremlin/console/jsr223/remote.yaml @@ -17,4 +17,4 @@ hosts: [localhost] port: 45940 -serializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4} \ No newline at end of file +responseSerializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4} \ No newline at end of file diff --git a/gremlin-driver/src/main/java/examples/Connections.java b/gremlin-driver/src/main/java/examples/Connections.java index 60f1bbe749..3c26a37856 100644 --- a/gremlin-driver/src/main/java/examples/Connections.java +++ b/gremlin-driver/src/main/java/examples/Connections.java @@ -77,7 +77,7 @@ public class Connections { maxConnections(8). path("/gremlin"). port(SERVER_PORT). - serializer(new GraphBinaryMessageSerializerV4()). + responseSerializer(new GraphBinaryMessageSerializerV4()). create(); GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster, "g")); @@ -95,7 +95,7 @@ public class Connections { MessageSerializer serializer = new GraphBinaryMessageSerializerV4(typeSerializerRegistry); Cluster cluster = Cluster.build(SERVER_HOST). port(SERVER_PORT). - serializer(serializer). + responseSerializer(serializer). create(); Client client = cluster.connect(); GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(client, "g")); diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java index a4b8676603..45b47993b6 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Cluster.java @@ -188,7 +188,7 @@ public final class Cluster { addresses.stream().skip(1).forEach(builder::addContactPoint); try { - builder.serializer(settings.serializer.create()); + builder.responseSerializer(settings.responseSerializer.create()); } catch (Exception ex) { throw new IllegalStateException("Could not establish serializer - " + ex.getMessage()); } @@ -522,7 +522,7 @@ public final class Cluster { private final List<InetAddress> addresses = new ArrayList<>(); private int port = 8182; private String path = "/gremlin"; - private MessageSerializer<?> serializer = null; + private MessageSerializer<?> responseSerializer = null; private int nioPoolSize = Runtime.getRuntime().availableProcessors(); private int workerPoolSize = Runtime.getRuntime().availableProcessors() * 2; private int maxConnections = ConnectionPool.MAX_POOL_SIZE; @@ -588,29 +588,34 @@ public final class Cluster { } /** - * Set the {@link MessageSerializer} to use given the exact name of a {@link Serializers} enum. Note that - * setting this value this way will not allow specific configuration of the serializer itself. If specific - * configuration is required * please use {@link #serializer(MessageSerializer)}. + * Set the {@link MessageSerializer} used to deserialize responses from the server given the exact name of a + * {@link Serializers} enum. This selects the encoding requested via the {@code Accept} header; requests are + * always sent as JSON regardless of this setting. Note that setting this value this way will not allow specific + * configuration of the serializer itself. If specific configuration is required please use + * {@link #responseSerializer(MessageSerializer)}. */ - public Builder serializer(final String mimeType) { - serializer = Serializers.valueOf(mimeType).simpleInstance(); + public Builder responseSerializer(final String mimeType) { + responseSerializer = Serializers.valueOf(mimeType).simpleInstance(); return this; } /** - * Set the {@link MessageSerializer} to use via the {@link Serializers} enum. If specific configuration is - * required please use {@link #serializer(MessageSerializer)}. + * Set the {@link MessageSerializer} used to deserialize responses from the server via the {@link Serializers} + * enum. This selects the encoding requested via the {@code Accept} header; requests are always sent as JSON + * regardless of this setting. If specific configuration is required please use + * {@link #responseSerializer(MessageSerializer)}. */ - public Builder serializer(final Serializers mimeType) { - serializer = mimeType.simpleInstance(); + public Builder responseSerializer(final Serializers mimeType) { + responseSerializer = mimeType.simpleInstance(); return this; } /** - * Sets the {@link MessageSerializer} to use. + * Sets the {@link MessageSerializer} used to deserialize responses from the server. This selects the encoding + * requested via the {@code Accept} header; requests are always sent as JSON regardless of this setting. */ - public Builder serializer(final MessageSerializer<?> serializer) { - this.serializer = serializer; + public Builder responseSerializer(final MessageSerializer<?> responseSerializer) { + this.responseSerializer = responseSerializer; return this; } @@ -1014,7 +1019,7 @@ public final class Cluster { public Cluster create() { if (addresses.isEmpty()) addContactPoint("localhost"); - if (null == serializer) serializer = Serializers.GRAPHBINARY_V4.simpleInstance(); + if (null == responseSerializer) responseSerializer = Serializers.GRAPHBINARY_V4.simpleInstance(); if (null != auth) interceptors.add(auth); return new Cluster(this); } @@ -1137,7 +1142,7 @@ public final class Cluster { path = builder.path; this.factory = new Factory(builder.nioPoolSize); - this.serializer = builder.serializer; + this.serializer = builder.responseSerializer; this.executor = new ScheduledThreadPoolExecutor(builder.workerPoolSize, new BasicThreadFactory.Builder().namingPattern("gremlin-driver-worker-%d").build()); diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java index cf24ca194a..9209209b97 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Settings.java @@ -60,10 +60,11 @@ public final class Settings { public List<String> hosts = new ArrayList<>(); /** - * The serializer that will be used when communicating with the server. Note that serializer settings should match - * what is available on the server. + * The serializer used to deserialize responses from the server. This selects the encoding requested via the + * {@code Accept} header; requests are always sent as JSON regardless of this setting. Note that this serializer + * should be supported by the server configuration. */ - public SerializerSettings serializer = new SerializerSettings(); + public SerializerSettings responseSerializer = new SerializerSettings(); /** * Settings for connections and connection pool. @@ -107,7 +108,7 @@ public final class Settings { final Constructor constructor = new Constructor(Settings.class, options); final TypeDescription settingsDescription = new TypeDescription(Settings.class); settingsDescription.addPropertyParameters("hosts", String.class); - settingsDescription.addPropertyParameters("serializer", SerializerSettings.class); + settingsDescription.addPropertyParameters("responseSerializer", SerializerSettings.class); constructor.addTypeDescription(settingsDescription); final Yaml yaml = new Yaml(constructor); @@ -138,20 +139,20 @@ public final class Settings { if (conf.containsKey("hosts")) settings.hosts = conf.getList("hosts").stream().map(Object::toString).collect(Collectors.toList()); - if (conf.containsKey("serializer.className")) { + if (conf.containsKey("responseSerializer.className")) { final SerializerSettings serializerSettings = new SerializerSettings(); - final Configuration serializerConf = conf.subset("serializer"); + final Configuration serializerConf = conf.subset("responseSerializer"); if (serializerConf.containsKey("className")) serializerSettings.className = serializerConf.getString("className"); - final Configuration serializerConfigConf = conf.subset("serializer.config"); + final Configuration serializerConfigConf = conf.subset("responseSerializer.config"); if (IteratorUtils.count(serializerConfigConf.getKeys()) > 0) { final Map<String,Object> m = new HashMap<>(); serializerConfigConf.getKeys().forEachRemaining(name -> m.put(name, serializerConfigConf.getProperty(name))); serializerSettings.config = m; } - settings.serializer = serializerSettings; + settings.responseSerializer = serializerSettings; } final Configuration connectionPoolConf = conf.subset("connectionPool"); diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java index 5196563304..9a80fe2235 100644 --- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java +++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/ProfilingApplication.java @@ -209,7 +209,7 @@ public class ProfilingApplication { .maxConnections(maxConnectionPoolSize) .nioPoolSize(nioPoolSize) .maxWaitForConnection(maxWaitForConnection) - .serializer(Serializers.valueOf(serializer)) + .responseSerializer(Serializers.valueOf(serializer)) .workerPoolSize(workerPoolSize).create(); try { diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ClientBehaviorIntegrateTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ClientBehaviorIntegrateTest.java index bc97268977..56f3da64e9 100644 --- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ClientBehaviorIntegrateTest.java +++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ClientBehaviorIntegrateTest.java @@ -86,7 +86,7 @@ public class ClientBehaviorIntegrateTest { return Cluster.build("localhost") .validationRequest(SocketServerConstants.GREMLIN_SINGLE_VERTEX) .port(PORT) - .serializer(new GraphBinaryMessageSerializerV4()); + .responseSerializer(new GraphBinaryMessageSerializerV4()); } private static void clearLogs() { diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/SettingsTest.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/SettingsTest.java index 6af84c2aca..24b5fd4534 100644 --- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/SettingsTest.java +++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/SettingsTest.java @@ -44,8 +44,8 @@ public class SettingsTest { conf.setProperty("auth.username", "user1"); conf.setProperty("auth.password", "password1"); conf.setProperty("hosts", Arrays.asList("255.0.0.1", "255.0.0.2", "255.0.0.3")); - conf.setProperty("serializer.className", "my.serializers.MySerializer"); - conf.setProperty("serializer.config.any", "thing"); + conf.setProperty("responseSerializer.className", "my.serializers.MySerializer"); + conf.setProperty("responseSerializer.config.any", "thing"); conf.setProperty("enableUserAgentOnConnect", false); conf.setProperty("bulkResults", true); conf.setProperty("connectionPool.enableSsl", true); @@ -84,8 +84,8 @@ public class SettingsTest { assertEquals("user1", settings.auth.username); assertEquals("password1", settings.auth.password); assertEquals(Arrays.asList("255.0.0.1", "255.0.0.2", "255.0.0.3"), settings.hosts); - assertEquals("my.serializers.MySerializer", settings.serializer.className); - assertEquals("thing", settings.serializer.config.get("any")); + assertEquals("my.serializers.MySerializer", settings.responseSerializer.className); + assertEquals("thing", settings.responseSerializer.config.get("any")); assertEquals(false, settings.enableUserAgentOnConnect); assertTrue(settings.bulkResults); assertThat(settings.connectionPool.enableSsl, is(true)); diff --git a/gremlin-examples/gremlin-java/Connections.java b/gremlin-examples/gremlin-java/Connections.java index 3bbbebcbeb..310a80051b 100644 --- a/gremlin-examples/gremlin-java/Connections.java +++ b/gremlin-examples/gremlin-java/Connections.java @@ -78,7 +78,7 @@ public class Connections { maxConnections(8). path("/gremlin"). port(SERVER_PORT). - serializer(new GraphBinaryMessageSerializerV4()). + responseSerializer(new GraphBinaryMessageSerializerV4()). create(); GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster, "g")); @@ -96,7 +96,7 @@ public class Connections { MessageSerializer serializer = new GraphBinaryMessageSerializerV4(typeSerializerRegistry); Cluster cluster = Cluster.build(SERVER_HOST). port(SERVER_PORT). - serializer(serializer). + responseSerializer(serializer). create(); Client client = cluster.connect(); GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(client, "g")); diff --git a/gremlin-js/gremlin-javascript/lib/driver/connection.ts b/gremlin-js/gremlin-javascript/lib/driver/connection.ts index 1be591ca9a..391e27d5f9 100644 --- a/gremlin-js/gremlin-javascript/lib/driver/connection.ts +++ b/gremlin-js/gremlin-javascript/lib/driver/connection.ts @@ -46,7 +46,7 @@ export type ConnectionOptions = { pfx?: string | Buffer; preciseNumbers?: boolean; pdtRegistry?: any; - reader?: any; + responseSerializer?: any; rejectUnauthorized?: boolean; traversalSource?: string; headers?: Record<string, string | string[]>; @@ -62,7 +62,7 @@ export type ConnectionOptions = { * Represents a single connection to a Gremlin Server. */ export default class Connection extends EventEmitter { - private readonly _reader: any; + private readonly _responseSerializer: any; isOpen = true; traversalSource: string; @@ -81,9 +81,10 @@ export default class Connection extends EventEmitter { ) { super(); - this._reader = options.reader || (options.preciseNumbers === true ? createPreciseReader() : new GraphBinaryReader(ioc)); + this._responseSerializer = + options.responseSerializer || (options.preciseNumbers === true ? createPreciseReader() : new GraphBinaryReader(ioc)); if (options.pdtRegistry) { - this._reader.pdtRegistry = options.pdtRegistry; + this._responseSerializer.pdtRegistry = options.pdtRegistry; } this.traversalSource = options.traversalSource || 'g'; this._enableUserAgentOnConnect = options.enableUserAgentOnConnect !== false; @@ -186,7 +187,7 @@ export default class Connection extends EventEmitter { let completed = false; try { - yield* this._reader.readResponseStream(streamReader); + yield* this._responseSerializer.readResponseStream(streamReader); completed = true; } finally { if (!completed) { @@ -198,11 +199,11 @@ export default class Connection extends EventEmitter { #getReaderForContentType(contentType: string | null) { if (!contentType) { - return this._reader; + return this._responseSerializer; } - if (contentType === this._reader.mimeType) { - return this._reader; + if (contentType === this._responseSerializer.mimeType) { + return this._responseSerializer; } return null; @@ -210,7 +211,7 @@ export default class Connection extends EventEmitter { async #makeHttpRequest(request: RequestMessage, signal?: AbortSignal): Promise<Response> { const headers: Record<string, string> = { - 'Accept': this._reader.mimeType, + 'Accept': this._responseSerializer.mimeType, }; if (this._enableUserAgentOnConnect) { @@ -293,7 +294,7 @@ export default class Connection extends EventEmitter { } if (!reader) { - throw new Error(`Response Content-Type '${contentType}' does not match the configured reader (expected '${this._reader.mimeType}')`); + throw new Error(`Response Content-Type '${contentType}' does not match the configured response serializer (expected '${this._responseSerializer.mimeType}')`); } const deserialized = await reader.readResponse(buffer); diff --git a/gremlin-js/gremlin-javascript/test/unit/graphbinary/precise-mode-test.js b/gremlin-js/gremlin-javascript/test/unit/graphbinary/precise-mode-test.js index 259642aa89..d02e889b99 100644 --- a/gremlin-js/gremlin-javascript/test/unit/graphbinary/precise-mode-test.js +++ b/gremlin-js/gremlin-javascript/test/unit/graphbinary/precise-mode-test.js @@ -504,18 +504,18 @@ describe('Precise Mode Tests', () => { describe('Connection option wiring', () => { it('preciseNumbers: true uses a precise reader', () => { const conn = new Connection('http://localhost:8182', { preciseNumbers: true }); - assert.ok(conn._reader !== graphBinaryReader); + assert.ok(conn._responseSerializer !== graphBinaryReader); }); - it('explicit reader takes precedence over preciseNumbers', () => { + it('explicit responseSerializer takes precedence over preciseNumbers', () => { const customReader = { custom: true }; - const conn = new Connection('http://localhost:8182', { reader: customReader, preciseNumbers: true }); - assert.strictEqual(conn._reader, customReader); + const conn = new Connection('http://localhost:8182', { responseSerializer: customReader, preciseNumbers: true }); + assert.strictEqual(conn._responseSerializer, customReader); }); it('default uses the default reader', () => { const conn = new Connection('http://localhost:8182', {}); - assert.ok(conn._reader instanceof graphBinaryReader.constructor); + assert.ok(conn._responseSerializer instanceof graphBinaryReader.constructor); }); }); }); diff --git a/gremlin-js/gremlin-javascript/test/unit/pdt-registry-test.js b/gremlin-js/gremlin-javascript/test/unit/pdt-registry-test.js index ded764b7c6..4b3b629ad3 100644 --- a/gremlin-js/gremlin-javascript/test/unit/pdt-registry-test.js +++ b/gremlin-js/gremlin-javascript/test/unit/pdt-registry-test.js @@ -150,7 +150,7 @@ describe('pdtRegistry wiring through Client/Connection', () => { }); const conn = new Connection('http://localhost:8182', { pdtRegistry: registry }); - assert.strictEqual(conn._reader.pdtRegistry, registry); + assert.strictEqual(conn._responseSerializer.pdtRegistry, registry); }); it('should set pdtRegistry on the reader when passed via Client options', () => { @@ -161,14 +161,14 @@ describe('pdtRegistry wiring through Client/Connection', () => { }); const client = new Client('http://localhost:8182', { pdtRegistry: registry }); - assert.strictEqual(client._connection._reader.pdtRegistry, registry); + assert.strictEqual(client._connection._responseSerializer.pdtRegistry, registry); }); it('should not leak pdtRegistry between connections', () => { const registry = new ProviderDefinedTypeRegistry(); const conn1 = new Connection('http://localhost:8182', { pdtRegistry: registry }); const conn2 = new Connection('http://localhost:8182'); - assert.isNull(conn2._reader.pdtRegistry); - assert.strictEqual(conn1._reader.pdtRegistry, registry); + assert.isNull(conn2._responseSerializer.pdtRegistry); + assert.strictEqual(conn1._responseSerializer.pdtRegistry, registry); }); }); diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java index 54b811d6e4..bb0dab92e6 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/remote/RemoteWorld.java @@ -50,7 +50,7 @@ public abstract class RemoteWorld implements World { * construct a RemoteWorld. */ public static Cluster createTestCluster(final Serializers serializer) { - return TestClientFactory.build().serializer(serializer).create(); + return TestClientFactory.build().responseSerializer(serializer).create(); } public RemoteWorld(Cluster cluster) { diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java index 63c334d25a..2b78ada396 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java @@ -289,7 +289,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration @Test public void shouldWorkWithGraphSONResponse() throws Exception { final Cluster cluster = TestClientFactory.build() - .serializer(Serializers.GRAPHSON_V4.simpleInstance()).create(); + .responseSerializer(Serializers.GRAPHSON_V4.simpleInstance()).create(); try { final Client client = cluster.connect(); @@ -307,7 +307,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration @Test public void shouldWorkWithJsonRequestAndGraphBinaryResponse() throws Exception { final Cluster cluster = TestClientFactory.build() - .serializer(Serializers.GRAPHBINARY_V4.simpleInstance()).create(); + .responseSerializer(Serializers.GRAPHBINARY_V4.simpleInstance()).create(); try { final Client client = cluster.connect(); @@ -320,7 +320,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration @Test public void shouldWorkWithJsonRequestAndGraphSONResponse() throws Exception { final Cluster cluster = TestClientFactory.build() - .serializer(Serializers.GRAPHSON_V4.simpleInstance()).create(); + .responseSerializer(Serializers.GRAPHSON_V4.simpleInstance()).create(); try { final Client client = cluster.connect(); @@ -355,7 +355,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration @Ignore("Reading for streaming GraphSON is not supported") @Test public void shouldReportErrorWhenRequestCantBeSerialized() throws Exception { - final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V4).create(); + final Cluster cluster = TestClientFactory.build().responseSerializer(Serializers.GRAPHSON_V4).create(); try { final Client client = cluster.connect().alias("g"); @@ -900,7 +900,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration @Test public void shouldWorkWithGraphBinaryV4Serialization() throws Exception { - final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHBINARY_V4).create(); + final Cluster cluster = TestClientFactory.build().responseSerializer(Serializers.GRAPHBINARY_V4).create(); final Client client = cluster.connect(); try { @@ -1117,7 +1117,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration @Test public void shouldAliasTraversalSourceVariables() throws Exception { - final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHBINARY_V4).create(); + final Cluster cluster = TestClientFactory.build().responseSerializer(Serializers.GRAPHBINARY_V4).create(); final Client client = cluster.connect(); try { try { @@ -1342,7 +1342,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration registry.register(new TestPointAdapter()); final Cluster cluster = TestClientFactory.build() - .serializer(new GraphBinaryMessageSerializerV4(TypeSerializerRegistry.INSTANCE, registry)) + .responseSerializer(new GraphBinaryMessageSerializerV4(TypeSerializerRegistry.INSTANCE, registry)) .create(); try { final DriverRemoteConnection connection = DriverRemoteConnection.using(cluster); @@ -1365,7 +1365,7 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration registry.register(TestAnnotatedPoint.class); final Cluster cluster = TestClientFactory.build() - .serializer(new GraphBinaryMessageSerializerV4(TypeSerializerRegistry.INSTANCE, registry)) + .responseSerializer(new GraphBinaryMessageSerializerV4(TypeSerializerRegistry.INSTANCE, registry)) .create(); try { final DriverRemoteConnection connection = DriverRemoteConnection.using(cluster); diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java index f7c61d84b5..6fbb426f04 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java @@ -82,7 +82,7 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat @Before public void beforeTest() { - cluster = TestClientFactory.build().serializer(messageSerializer).create(); + cluster = TestClientFactory.build().responseSerializer(messageSerializer).create(); client = cluster.connect(); } diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSerializationIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSerializationIntegrateTest.java index 0d3f54a59a..ccf582fd89 100644 --- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSerializationIntegrateTest.java +++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerSerializationIntegrateTest.java @@ -87,7 +87,7 @@ public class GremlinServerSerializationIntegrateTest extends AbstractGremlinServ @Before public void openConnection() { - cluster = TestClientFactory.build().serializer(serializer).create(); + cluster = TestClientFactory.build().responseSerializer(serializer).create(); client = cluster.connect(); // VertexProperty related test tun on crew graph diff --git a/gremlin-server/src/test/resources/conf/remote-objects.yaml b/gremlin-server/src/test/resources/conf/remote-objects.yaml index 37e1caaa8d..d59161a401 100644 --- a/gremlin-server/src/test/resources/conf/remote-objects.yaml +++ b/gremlin-server/src/test/resources/conf/remote-objects.yaml @@ -28,4 +28,4 @@ hosts: [localhost] port: 45940 -serializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4 } \ No newline at end of file +responseSerializer: { className: org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV4 } \ No newline at end of file
