This is an automated email from the ASF dual-hosted git repository. Cole-Greer pushed a commit to branch GLVBehaviouralAlignment in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 51149faae9aab6c01a529a3ae8a607a399ab8dab Author: Cole Greer <[email protected]> AuthorDate: Thu Jul 16 14:26:20 2026 -0700 Reuse ResponseException for .NET deserialization failures Replace the newly-added ResponseDeserializationException with a second ResponseException constructor, keeping a single exception type for driver-level response failures (server-reported status errors and local deserialization failures) and matching the reuse-over-new-type approach taken in gremlin-javascript for the analogous case. --- .../src/Gremlin.Net/Driver/Connection.cs | 2 +- .../Exceptions/ResponseDeserializationException.cs | 42 ---------------------- .../Driver/Exceptions/ResponseException.cs | 21 ++++++++++- .../Driver/ClientBehaviorIntegrationTests.cs | 6 ++-- 4 files changed, 25 insertions(+), 46 deletions(-) diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs index 62a40be264..090feb702c 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs @@ -384,7 +384,7 @@ namespace Gremlin.Net.Driver and not HttpIOException) { channel.Writer.Complete( - new ResponseDeserializationException(ex)); + new ResponseException(ex)); } catch (Exception ex) { diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseDeserializationException.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseDeserializationException.cs deleted file mode 100644 index 01912507c6..0000000000 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseDeserializationException.cs +++ /dev/null @@ -1,42 +0,0 @@ -#region License - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#endregion - -using System; - -namespace Gremlin.Net.Driver.Exceptions -{ - /// <summary> - /// The exception that is thrown when the driver fails to deserialize a response received from Gremlin Server. - /// </summary> - public class ResponseDeserializationException : Exception - { - /// <summary> - /// Initializes a new instance of the <see cref="ResponseDeserializationException" /> class. - /// </summary> - /// <param name="innerException">The exception that caused the deserialization failure.</param> - public ResponseDeserializationException(Exception innerException) - : base("Failed to deserialize the response received from Gremlin Server.", innerException) - { - } - } -} diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs index 0dbac9c12a..b334dffdd9 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Exceptions/ResponseException.cs @@ -44,7 +44,26 @@ namespace Gremlin.Net.Driver.Exceptions } /// <summary> - /// Gets the status code from the GraphBinary status footer. + /// Initializes a new instance of the <see cref="ResponseException" /> class for a response that + /// could not be deserialized. There is no status code from the server in this case since the + /// failure occurred locally while reading the response. + /// </summary> + /// <param name="innerException">The exception that caused the deserialization failure.</param> + public ResponseException(Exception innerException) + : base("Failed to deserialize the response received from Gremlin Server.", innerException) + { + StatusCode = NoStatusCode; + } + + /// <summary> + /// The <see cref="StatusCode" /> value used when the exception was not raised from a status + /// code reported by the server (e.g. a local deserialization failure). + /// </summary> + public const int NoStatusCode = -1; + + /// <summary> + /// Gets the status code from the GraphBinary status footer, or <see cref="NoStatusCode" /> if this + /// exception represents a local deserialization failure rather than a server-reported error. /// </summary> public int StatusCode { get; } diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ClientBehaviorIntegrationTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ClientBehaviorIntegrationTests.cs index cb346adb20..c736fed24a 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ClientBehaviorIntegrationTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/ClientBehaviorIntegrationTests.cs @@ -173,11 +173,12 @@ namespace Gremlin.Net.IntegrationTest.Driver { SkipIfServerUnavailable(); - var ex = await Assert.ThrowsAsync<ResponseDeserializationException>(async () => + var ex = await Assert.ThrowsAsync<ResponseException>(async () => { var resultSet = await _client!.SubmitAsync<dynamic>(SocketServerConstants.GremlinMalformedResponse); await resultSet.ToListAsync(); }); + Assert.Equal(ResponseException.NoStatusCode, ex.StatusCode); Assert.NotNull(ex.InnerException); // Recovery @@ -191,11 +192,12 @@ namespace Gremlin.Net.IntegrationTest.Driver { SkipIfServerUnavailable(); - var ex = await Assert.ThrowsAsync<ResponseDeserializationException>(async () => + var ex = await Assert.ThrowsAsync<ResponseException>(async () => { var resultSet = await _client!.SubmitAsync<dynamic>(SocketServerConstants.GremlinEmptyBody); await resultSet.ToListAsync(); }); + Assert.Equal(ResponseException.NoStatusCode, ex.StatusCode); Assert.IsType<System.IO.IOException>(ex.InnerException); Assert.Contains("Unexpected end of stream", ex.InnerException!.Message);
