Skip to content

Conversation

@minwoox
Copy link
Contributor

@minwoox minwoox commented Nov 27, 2025

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.

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`.
@minwoox minwoox added this to the 1.34.0 milestone Nov 27, 2025
@minwoox minwoox requested a review from ikhoon as a code owner November 27, 2025 09:48
@coderabbitai
Copy link

coderabbitai bot commented Nov 27, 2025

Walkthrough

The DefaultStreamMessage.cancel() method is updated to dynamically create a close event via newCloseEvent(CancelledSubscriptionException.get()) instead of using a pre-defined CANCELLED_CLOSE constant when transitioning to the CLEANUP state.

Changes

Cohort / File(s) Summary
Subscription cancellation event handling
core/src/main/java/com/linecorp/armeria/common/stream/DefaultStreamMessage.java
Modified cancel() method to create a new CloseEvent dynamically for cancelled subscriptions instead of using a constant; updated accompanying comment

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single file with localized change to event creation logic
  • Straightforward substitution of constant with dynamic event instantiation
  • No structural or functional complexity introduced

Poem

A hop, a skip, a close event freed,
No constant chains where once they'd be,
Fresh exceptions dance in the stream's decree,
Cancellations bloom more gracefully! 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: preserving stack traces for CancelledSubscriptionException in the code modifications.
Description check ✅ Passed The description is well-structured and clearly related to the changeset, explaining motivation, modifications, and results for preserving stack traces.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f770430 and 99e169f.

📒 Files selected for processing (1)
  • core/src/main/java/com/linecorp/armeria/common/stream/DefaultStreamMessage.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/src/main/java/com/linecorp/armeria/common/stream/DefaultStreamMessage.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: Kubernetes Chaos test
  • GitHub Check: build-ubicloud-standard-16-jdk-17-min-java-17-coverage
  • GitHub Check: build-windows-latest-jdk-21
  • GitHub Check: build-ubicloud-standard-16-jdk-8
  • GitHub Check: build-macos-latest-jdk-21
  • GitHub Check: build-ubicloud-standard-16-jdk-11
  • GitHub Check: build-ubicloud-standard-16-jdk-21-snapshot-blockhound
  • GitHub Check: build-ubicloud-standard-16-jdk-17-leak
  • GitHub Check: build-ubicloud-standard-16-jdk-17-min-java-11
  • GitHub Check: lint
  • GitHub Check: site
  • GitHub Check: flaky-tests
  • GitHub Check: Summary

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍

Comment on lines 141 to 145
if (cause == CancelledSubscriptionException.INSTANCE) {
return CANCELLED_CLOSE;
} else if (cause == AbortedStreamException.INSTANCE) {
return ABORTED_CLOSE;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the stacktrace of cause is already empty, I think we can keep the original behavior.

final SubscriptionImpl subscription = this.subscription;
assert subscription != null;
notifySubscriberOfCloseEvent(subscription, CANCELLED_CLOSE);
notifySubscriberOfCloseEvent(subscription, new CloseEvent(CancelledSubscriptionException.get()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use cached CloseEvent if CancelledSubscriptionException.get() returns CancelledSubscriptionException.INSTANCE.

Suggested change
notifySubscriberOfCloseEvent(subscription, new CloseEvent(CancelledSubscriptionException.get()));
notifySubscriberOfCloseEvent(subscription, newCloseEvent(CancelledSubscriptionException.get()));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! updated. 😉

@codecov
Copy link

codecov bot commented Nov 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.18%. Comparing base (8150425) to head (99e169f).
⚠️ Report is 262 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6525      +/-   ##
============================================
- Coverage     74.46%   74.18%   -0.29%     
- Complexity    22234    23393    +1159     
============================================
  Files          1963     2102     +139     
  Lines         82437    87568    +5131     
  Branches      10764    11496     +732     
============================================
+ Hits          61385    64960    +3575     
- Misses        15918    17129    +1211     
- Partials       5134     5479     +345     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@minwoox minwoox merged commit 5ec2d86 into line:main Nov 28, 2025
17 checks passed
@minwoox minwoox deleted the cancel_stacktrace branch November 28, 2025 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants