Skip to content

Commit

Permalink
Fill the stack trace of ResponseCompleteException when sampled (#5972)
Browse files Browse the repository at this point in the history
Motivation:

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

Discord thread:
https://discord.com/channels/1087271586832318494/1087272728177942629/1303562249629073520

Modifications:

- Create a new instance if `ResponseCompletionException` is sampled by
`verboseExceptionSampler`

Result:

You can now sample the stack trace of `ResponseCompleteException` with
`verboseExceptionSampler`.
  • Loading branch information
ikhoon authored Nov 28, 2024
1 parent 08f6a0b commit 6963c92
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,22 @@ 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.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 6963c92

Please sign in to comment.