Repository navigation
fix: route sneaky-thrown checked exceptions from element effects to the error handler (#25508) (CP: 25.2) - #25515
Merged
Conversation
…he error handler (#25508) `ElementEffect` only caught `RuntimeException` from the effect action, so a checked exception thrown without being declared ("sneaky throws", as produced by Kotlin or Lombok's `@SneakyThrows`) escaped past the effect machinery and ended up in the current thread's uncaught exception handler instead of the error handler of the component's Vaadin session. Fixes #25506 ## What changed - `ElementEffect.executeAction` now catches `Exception` rather than `RuntimeException`, so a sneaky-thrown checked exception is handed to the session error handler unwrapped, exactly like a `RuntimeException` already was. - `DeniedSignalUsageException` keeps its dedicated `catch` ahead of the generic one, so it still propagates immediately to the caller (e.g. inside a `bindChildren` factory) instead of being swallowed by the error handler. - The probe/unattached path is restructured: when there is no error handler yet, the effect function now runs *outside* any `try`/`catch` and returns early, instead of being caught and re-thrown. This avoids needing a helper that re-throws checked exceptions undeclared, and removes a re-throw line that coverage analysis could never mark as executed (a line that only ever completes by throwing is not counted as covered). - Javadoc/comments updated to say exceptions are "not caught" in probe mode rather than "re-thrown", and to explain why the catch is on `Exception`. No public or protected API changed — the behaviour change is entirely inside the private `executeAction` method. ## Test summary | # | Status | What the test verifies | Why it matters | |---|--------|------------------------|----------------| | 1 | ✅ | A checked exception sneaky-thrown from an effect on an attached component is passed to the session error handler, and the `ErrorEvent` carries the *same* exception instance (not a wrapper) | This is the bug being fixed; without it such exceptions bypass the application's error handling entirely | | 2 | ✅ | During the detached probe run (no error handler available yet) the checked exception propagates as-is out of `Signal.effect`, reaching the thread's uncaught exception handler unwrapped | Widening the catch must not start swallowing or wrapping exceptions in probe mode, where the caller is expected to see them | | 3 | ✅ | A plain `RuntimeException` from an effect still reaches the error handler, both on a direct run and on an asynchronous re-run | Guards against a regression in the pre-existing, far more common path (covered by tests already on `main`) | | 4 | ✅ | `DeniedSignalUsageException` is still thrown to the caller rather than routed to the error handler | The new broad `catch (Exception)` sits right after this one; if ordering broke, illegal signal usage would silently become an error event | Tests added on this branch: - `ElementEffectTest.effect_sneakyThrowCheckedException_delegatedToErrorHandler` → row 1 - `ElementEffectTest.effect_notAttached_sneakyThrowCheckedException_rethrownUnwrapped` → row 2 - Private helper `ElementEffectTest.sneakyThrow` (throws an undeclared checked exception, mimicking Kotlin / `@SneakyThrows`) supports rows 1 and 2 and asserts nothing itself. Rows 3 and 4 are pinned by tests that already existed on `main` (`effect_throwExceptionWhenRunningDirectly_delegatedToErrorHandler`, `effect_throwExceptionWhenRunningAsynchronously_delegatedToErrorHandler`, and the `DeniedSignalUsageException` assertion in the `bindChildren` factory test); they were left unchanged and serve as the regression net for this fix. Deliberately untested: the asynchronous re-run path for *checked* exceptions specifically. It goes through the same `executeAction` code as row 1 and is already covered for `RuntimeException` by row 3, so a dedicated variant would only duplicate existing coverage. Javadoc/comment wording changes carry no behaviour and are not tested. --------- Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com>
Collaborator
Author
|
This PR is eligible for auto-merging policy, so it has been approved automatically. If there are pending conditions, auto merge (with 'squash' method) has been enabled for this PR [Message is sent from bot] |
vaadin-review-bot
approved these changes
Sep 7, 2026
vaadin-bot
enabled auto-merge (squash)
September 7, 2026 10:57
|
Contributor
Collaborator
Author
|
This ticket/PR has been released with Vaadin 25.2.8. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This PR cherry-picks changes from the original PR #25508 to branch 25.2.
Original PR description