Skip to content

[Oztechan/CCC#4796] Make TerminationException extend CancellationException#4797

Merged
mustafaozhan merged 1 commit into
developfrom
4796/make-terminationexception-extend-cancellationexception
Jul 15, 2026
Merged

[Oztechan/CCC#4796] Make TerminationException extend CancellationException#4797
mustafaozhan merged 1 commit into
developfrom
4796/make-terminationexception-extend-cancellationexception

Conversation

@mustafaozhan

Copy link
Copy Markdown
Member

BaseNetworkService maps library exceptions into the project error taxonomy, incl. is CancellationException -> TerminationException(e). But TerminationException extended Throwable, so a cancelled coroutine threw a non-cancellation exception — breaking structured concurrency (parent treats the child as failed, not cancelled) and producing Parent job is Cancelling stack-dump noise.

Fix: TerminationException now extends CancellationException (via the common CancellationException(message) constructor) instead of Throwable. The library→project mapping is unchanged, so the abstraction is preserved — but the framework now recognises it as cancellation and unwinds cleanly.

The existing BaseNetworkServiceTest (assertFailsWith(TerminationException::class)) still holds — cancellation still maps to TerminationException.

✅ Verified: :common:core:network:jvmTest passes. Mirrors Oztechan/AdTrack#57.

Resolves #4796

@mustafaozhan mustafaozhan requested a review from a team as a code owner July 12, 2026 22:26
Copilot AI review requested due to automatic review settings July 12, 2026 22:26
@codacy-production

codacy-production Bot commented Jul 12, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.00% coverage variation

Metric Results
Coverage variation +0.00% coverage variation
Diff coverage 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (49b365d) 3341 1746 52.26%
Head commit (378b410) 3341 (+0) 1746 (+0) 52.26% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4797) 1 1 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the project’s cancellation error wrapper so that coroutine cancellations remain true cancellations under structured concurrency. By making TerminationException a CancellationException, parent jobs should treat the child as cancelled (not failed), avoiding “Parent job is Cancelling” failure noise while preserving the library→project error mapping.

Changes:

  • Change TerminationException to extend kotlinx.coroutines.CancellationException instead of Throwable.
  • Add a brief comment explaining the structured-concurrency rationale for the type change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Maps coroutine cancellation into the project's error taxonomy. Extends CancellationException (not
// Throwable) so structured concurrency still recognises it as cancellation and unwinds cleanly.
internal class TerminationException(cause: Throwable) : CancellationException(cause.message)
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.29%. Comparing base (49b365d) to head (378b410).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4797   +/-   ##
========================================
  Coverage    55.29%   55.29%           
========================================
  Files          169      169           
  Lines         3033     3033           
  Branches       452      452           
========================================
  Hits          1677     1677           
  Misses        1331     1331           
  Partials        25       25           

Impacted file tree graph

Files with missing lines Coverage Δ
.../common/core/network/error/TerminationException.kt 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@mustafaozhan mustafaozhan merged commit 00e47cc into develop Jul 15, 2026
18 checks passed
@mustafaozhan mustafaozhan deleted the 4796/make-terminationexception-extend-cancellationexception branch July 15, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make TerminationException extend CancellationException

2 participants