From 093ab06530dda0f36d46bbd2fbbb513abc2852d5 Mon Sep 17 00:00:00 2001 From: Kun Zhang Date: Mon, 25 Jul 2016 09:58:58 -0700 Subject: [PATCH] core: Log a warning in ClientCall.cancel if no detail is provided. Resolves #2054 --- .../src/main/java/io/grpc/internal/ClientCallImpl.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/io/grpc/internal/ClientCallImpl.java b/core/src/main/java/io/grpc/internal/ClientCallImpl.java index aacbba80cc..5b0d4c2de2 100644 --- a/core/src/main/java/io/grpc/internal/ClientCallImpl.java +++ b/core/src/main/java/io/grpc/internal/ClientCallImpl.java @@ -328,6 +328,10 @@ final class ClientCallImpl extends ClientCall @Override public void cancel(@Nullable String message, @Nullable Throwable cause) { + if (message == null && cause == null) { + cause = new CancellationException("Cancelled without a message or cause"); + log.log(Level.WARNING, "Cancelling without a message or cause is suboptimal", cause); + } if (cancelCalled) { return; } @@ -343,12 +347,6 @@ final class ClientCallImpl extends ClientCall if (cause != null) { status = status.withCause(cause); } - if (message == null && cause == null) { - // TODO(zhangkun83): log a warning with this exception once cancel() has been deleted from - // ClientCall. - status = status.withCause( - new CancellationException("Client called cancel() without any detail")); - } stream.cancel(status); } } finally {