Skip to content

Commit 5ec2d86

Browse files
authored
Preserve stack trace for CancelledSubscriptionException (#6525)
Motivation: When a `CancelledSubscriptionException` was raised, it was created without a stack trace for performance reasons. This made it difficult for developers to debug the root cause of a subscription cancellation. Modifications: - Used `CancelledSubscriptionException.get()` when creating a `CloseEvent`. - This method leverages the configured `verboseExceptionSampler` to determine whether a full stack trace should be captured and preserved. Result: - Developers can now obtain a full stack trace for `CancelledSubscriptionException` by configuring the `verboseExceptionSampler`.
1 parent 64d2a0f commit 5ec2d86

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/main/java/com/linecorp/armeria/common/stream/DefaultStreamMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ private void doRequest(long n) {
290290
final void cancel() {
291291
if (setState(State.OPEN, State.CLEANUP) || setState(State.CLOSED, State.CLEANUP)) {
292292
// It the state was CLOSED, close() or close(cause) has been called before cancel() or abort()
293-
// is called. We just ignore the previously pushed event and deal with CANCELLED_CLOSE.
293+
// is called. We just ignore the previously pushed event and deal with cancelled close event.
294294
final SubscriptionImpl subscription = this.subscription;
295295
assert subscription != null;
296-
notifySubscriberOfCloseEvent(subscription, CANCELLED_CLOSE);
296+
notifySubscriberOfCloseEvent(subscription, newCloseEvent(CancelledSubscriptionException.get()));
297297
}
298298
}
299299

0 commit comments

Comments
 (0)