core: Log a warning in ClientCall.cancel if no detail is provided.

Resolves #2054
This commit is contained in:
Kun Zhang 2016-07-25 09:58:58 -07:00
parent 841c7c4bfa
commit 093ab06530
1 changed files with 4 additions and 6 deletions

View File

@ -328,6 +328,10 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT>
@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<ReqT, RespT> extends ClientCall<ReqT, RespT>
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 {