Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SneakyThrows permits missing 'catch' blocks in checked-exception-throwing try-with-resource blocks within lambdas #1170

Open
hwaite opened this issue Jan 31, 2023 · 1 comment

Comments

@hwaite
Copy link

hwaite commented Jan 31, 2023

Short description

If 'try-with-resources' block throws checked exception from within a lambda, the lambda must catch or rethrow. The SneakyThrows annotation neuters this requirement. IDEA reports code as valid while compiler rejects.

Expected behavior

Compile error should be visible from IDE.

Version information

  • IDEA Version: IU-213.6461.79
  • **JDK Version:**11.0.16
  • OS Type & Version: Windows 10
  • Lombok Plugin Version: 213.6461.79
  • Lombok Dependency Version: 1.18.24

Steps to reproduce

@SneakyThrows
void foo() {
    Runnable r = () -> {
        try (Reader reader = new FileReader("")) {}
    }
}
Lekanich added a commit to Lekanich/lombok-intellij-plugin that referenced this issue Dec 16, 2023
* fix sneaky throws that can't handle the try inside lambda
@ybedrov
Copy link

ybedrov commented Feb 5, 2024

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

No branches or pull requests

2 participants