alex-plekhanov commented on code in PR #12732:
URL: https://github.com/apache/ignite/pull/12732#discussion_r2812109841
##########
modules/core/src/main/java/org/apache/ignite/internal/client/thin/TcpClientCache.java:
##########
@@ -1754,4 +1759,136 @@ private boolean canBlockTx(boolean isGetOp,
TransactionConcurrency concurrency,
return true;
}
+
+ /** */
+ private static ClientException convertException(Exception e, String
cacheName) {
+ String msg = "Failed to perform cache operation [cacheName=" +
cacheName + "]: " + e.getMessage();
+
+ // Exception can be ClientProtocolError - it's an internal exception,
can't be thrown to user.
+ if (!(e instanceof ClientException))
+ return new ClientException(msg, e);
+ else if (X.hasCause(e, ClientServerError.class)) // Wrap server errors.
+ return new ClientException(msg, e);
+ else // Don't wrap authentication, authorization, connection errors.
+ return (ClientException)e;
+ }
+
+ /** */
+ private static class ReliableChannelWrapper implements ReliableChannelEx {
+ /** */
+ private final ReliableChannelImpl delegate;
+
+ /** */
+ private final String cacheName;
+
+ /** */
+ public ReliableChannelWrapper(ReliableChannelImpl delegate, String
cacheName) {
+ this.delegate = delegate;
+ this.cacheName = cacheName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T service(
+ ClientOperation op,
+ Consumer<PayloadOutputChannel> payloadWriter,
+ Function<PayloadInputChannel, T> payloadReader
+ ) throws ClientException, ClientError {
+ try {
+ return delegate.service(op, payloadWriter, payloadReader);
+ }
+ catch (ClientException e) {
+ throw convertException(e, cacheName);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T service(
+ ClientOperation op,
+ Consumer<PayloadOutputChannel> payloadWriter,
+ Function<PayloadInputChannel, T> payloadReader,
+ List<UUID> targetNodes
+ ) throws ClientException, ClientError {
+ try {
+ return delegate.service(op, payloadWriter, payloadReader,
targetNodes);
+ }
+ catch (ClientException e) {
+ throw convertException(e, cacheName);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> IgniteClientFuture<T> serviceAsync(
+ ClientOperation op,
+ Consumer<PayloadOutputChannel> payloadWriter,
+ Function<PayloadInputChannel, T> payloadReader
+ ) throws ClientException, ClientError {
+ CompletableFuture<T> fut = new CompletableFuture<>();
+
+ delegate.serviceAsync(op, payloadWriter,
payloadReader).whenComplete((res, err) -> {
+ if (err != null)
+ fut.completeExceptionally(convertException((Exception)err,
cacheName));
Review Comment:
No, service should throws also only ClientExceptions, fixed, thanks.
Also `Async` methods never throw exceptions (at least `Client*` exceptions),
so method declarations are fixed too, to reflect actual exceptions possible in
`service*` methods.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]