Lombok-intellij-plugin: @SneakyThrows mistakenly swallow checked exception in lambda without "throws"

Created on 11 May 2020  路  6Comments  路  Source: mplushnikov/lombok-intellij-plugin

Short description

@SneakyThrows mistakenly swallow checked exception in lambda without "throws" in IDEA.

Expected behavior

Report an error in IDEA.

Version information

  • IDEA Version: _2019.3.3_
  • JDK Version: _1.8.0-242_
  • OS Type & Version: _Windows 10 Pro, 19041.207_
  • Lombok Plugin Version: _0.29-2019.3_
  • Lombok Dependency Version: _1.18.12_

Steps to reproduce

image

bug

Most helpful comment

I think I can fix it.

All 6 comments

this is a correct behavior for me, the lambda must not throw a checked exception as Runnable.run() did not, if you want use @SneakyThrows create a method encapsulating the body of your runnable and add this annotation on it.

this is a correct behavior for me, the lambda must not throw a checked exception as Runnable.run() did not, if you want use @SneakyThrows create a method encapsulating the body of your runnable and add this annotation on it.

I mean in the screenshot above, there should be a red underscore under throw new IOException("error"); and an error reported by the IDE.

鎵规敞 2020-05-22 174036

It鈥檚 already the case. There is an error under the throw exception

It鈥檚 already the case. There is an error under the throw exception

If you add @SneakyThrows, the error just disappears. But when compile the code using javac, there will be a same error in line 11 and line 18.

鎵规敞 2020-05-22 195737

It鈥檚 already the case. There is an error under the throw exception

If you add @SneakyThrows, the error just disappears. But when compile the code using javac, there will be a same error in line 11 and line 18.

鎵规敞 2020-05-22 195737

I think too that this case shouldn't be disabled inspection IDE

I think I can fix it.

Was this page helpful?
0 / 5 - 0 ratings