Lombok-intellij-plugin: @SneakyThrows hides compilation error: Variable might not have been not initialized

Created on 20 Sep 2020  路  3Comments  路  Source: mplushnikov/lombok-intellij-plugin

Describe the bug
The annotation @SneakyThrows hides compilation error that should be raised in the IDE. I use IntelliJ Idea 2020.1.4

To Reproduce
The following code doesn't compile, which is correct. Placing @SneakyThrows hides the red-wave underline in the IDE the file at the line log.error("File [{}] not found", file);. Removing such annotation leaves the file correctly detected by the IDE.

static Logger log = LoggerFactory.getLogger(Foo.class); // or @Slf4J, there is no difference in the behavior

@SneakyThrows
public static void main(String[] args) {

      boolean condition = true;

      final String file;
      final InputStream inputStream;
      try {
            if (condition) {
                file = "classpath:data/resource.json";
                inputStream = new FileInputStream(file);
            } else {
                file = "/app/mounted-resource/resource.json";
                inputStream = new FileInputStream(file);
            }
      } catch (IOException e) {
            log.error("File [{}] not found", file);
      }
 }

Version info:

  • Lombok version 1.18.12
  • javac 11.0.5
  • IntelliJ Idea 2020.1.4 (Ultimate eidition)
  • IntelliJ Lombok plugin 0.30-2020.1

Additional context
I know the code can be simplified to avoid such issue, however, this is the way to reproduce the behavior.

bug

All 3 comments

Yeah, I can reproduce it and I think I found the problem...

@Lekanich Looks great, I am impressed of the quick fix. What is the target release version? Will you close this issue after a retest or shall I take care of it by myself?

@Nikolas-Charalambidis It depends on @mplushnikov He is the owner of the repository.

Was this page helpful?
0 / 5 - 0 ratings