Skip to content

Commit

Permalink
Fill the stacktrace of ResponseCompleteException when `verboseRespo…
Browse files Browse the repository at this point in the history
…nses = true`

Motivation:

`ResponseCompleteException` is considered a safe exception to clean up
request resources. However, it would be a good idea to leave a
stacktrace in case there is a bug in the implementation or the user
wants to know how the error occurred.

Modifications:

- Create a new instance if `verboseResponse = true` and
  `ResponseCompletionException` is sampled by `verboseExceptionSampler`

Result:

You can now sees the stacktrace of `ResponseCompleteException` when
`Flags.verboseResponse()` is true.
  • Loading branch information
ikhoon committed Nov 7, 2024
1 parent 1bb781a commit 2d0ed0c
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@ public final class ResponseCompleteException extends CancellationException {

private static final long serialVersionUID = 6090278381004263949L;

private static final ResponseCompleteException INSTANCE = new ResponseCompleteException();
private static final ResponseCompleteException INSTANCE = new ResponseCompleteException(false);

/**
* Returns the singleton {@link ResponseCompleteException}.
*/
public static ResponseCompleteException get() {
return INSTANCE;
if (Flags.verboseResponses() &&
Flags.verboseExceptionSampler().isSampled(ResponseCompleteException.class)) {
return new ResponseCompleteException();
} else {
return INSTANCE;
}
}

private ResponseCompleteException() {
private ResponseCompleteException() {}

private ResponseCompleteException(@SuppressWarnings("unused") boolean dummy) {
super(null, null, false, false);
}
}

0 comments on commit 2d0ed0c

Please sign in to comment.