lombok-intellij-plugin icon indicating copy to clipboard operation
lombok-intellij-plugin copied to clipboard

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

Open hwaite opened this issue 2 years ago • 1 comments

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("")) {}
    }
}

hwaite avatar Jan 31 '23 04:01 hwaite

@mplushnikov https://github.com/JetBrains/intellij-community/pull/2629

ybedrov avatar Feb 05 '24 22:02 ybedrov