From 9063159a642e5998ef0c688250fe187f2b4d66e6 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Thu, 24 Oct 2024 02:54:20 +0200 Subject: [PATCH] Fix status code --- .../it/cavallium/rockserver/core/client/GrpcConnection.java | 3 ++- .../java/it/cavallium/rockserver/core/server/GrpcServer.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/cavallium/rockserver/core/client/GrpcConnection.java b/src/main/java/it/cavallium/rockserver/core/client/GrpcConnection.java index 2a17c4a..2bbfa52 100644 --- a/src/main/java/it/cavallium/rockserver/core/client/GrpcConnection.java +++ b/src/main/java/it/cavallium/rockserver/core/client/GrpcConnection.java @@ -9,6 +9,7 @@ import com.google.protobuf.ByteString; import com.google.protobuf.UnsafeByteOperations; import io.grpc.ManagedChannel; import io.grpc.Status; +import io.grpc.Status.Code; import io.grpc.StatusRuntimeException; import io.grpc.netty.NettyChannelBuilder; import io.netty.channel.epoll.EpollDomainSocketChannel; @@ -580,7 +581,7 @@ public class GrpcConnection extends BaseConnection implements RocksDBAPI { private static Throwable mapGrpcStatusError(@NotNull Throwable t) { if (t instanceof StatusRuntimeException statusRuntimeException - && statusRuntimeException.getStatus() == Status.INTERNAL + && statusRuntimeException.getStatus().getCode() == Code.INTERNAL && statusRuntimeException.getStatus().getDescription() != null && statusRuntimeException.getStatus().getDescription().startsWith(grpcRocksDbErrorPrefixString)) { var desc = statusRuntimeException.getStatus().getDescription(); diff --git a/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java b/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java index 1b48d03..09686a9 100644 --- a/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java +++ b/src/main/java/it/cavallium/rockserver/core/server/GrpcServer.java @@ -301,6 +301,7 @@ public class GrpcServer extends Server { @Override public Mono putGetChanged(PutRequest request) { return executeSync(() -> { + if(true) throw new RocksDBRetryException(); try (var arena = Arena.ofConfined()) { var changed = api.put(arena, request.getTransactionOrUpdateId(), @@ -564,7 +565,7 @@ public class GrpcServer extends Server { @Override protected Throwable onErrorMap(Throwable throwable) { var ex = handleError(throwable).asException(); - if (ex.getStatus().getCode() == Code.INTERNAL && !(throwable instanceof RocksDBException)) { + if (ex.getStatus().getCode() == Code.INTERNAL && !(throwable.getCause() instanceof RocksDBException)) { LOG.error("Unexpected internal error during request", ex); } return ex;