Skip to content

Quirk: finally overriding return and swallowing exceptions #96

Open

Description

@mperor

Goal: show why return inside finally is dangerous.

Show:

  • return in finally overrides the value returned from try
  • return in finally silently discards a thrown exception
  • modifying a returned reference vs a primitive inside finally
  • contrast with try-with-resources and suppressed exceptions

Where: FirstSteps/src/test/java/pl/mperor/lab/java/quirk

Activity

  1. added
    track:quirksSurprising behaviour and classic pitfalls
    dailyQueued for the daily learning PR
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dailyQueued for the daily learning PRtrack:quirksSurprising behaviour and classic pitfalls

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions