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

[BUG] @Cleanup compile failed when the close method throws an exception #3290

Open
yaojiqunaer opened this issue Nov 4, 2022 · 0 comments
Open

Comments

@yaojiqunaer
Copy link

Describe the bug

If the variable's close method throws an exception, it is likely to cause the compilation to fail

To Reproduce

the code like:

private void testCleanupCompileError() {
    @Cleanup BufferedInputStream inputStream =
            new BufferedInputStream(new ByteArrayInputStream("test".getBytes()));
}

and then use mvn install, unable to complete compilation and throw exception java.io.IOException

Reason here

Code generated by normal compilation with @Cleanup

private void testCleanupCompileError() {
    BufferedInputStream inputStream = new BufferedInputStream(new ByteArrayInputStream("test".getBytes()));
    if (Collections.singletonList(inputStream).get(0) != null) {
        inputStream.close();
    }
}

but the java.io.BufferedInputStream#close will throws IOException,however use @Cleanup he exception is not caught or thrown

Expected behavior

I don't know if it's a lombok design, that's it or bug. may hope the exception can be caught automatically.

Version info

  • Lombok version 1.18.24
  • Maven version apache-maven-3.3.9
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

1 participant