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

Fixed language server crashing because of wrong Lombok jar #2542

Conversation

mathieufortin01
Copy link
Contributor

vscode-java: 1.8.0
running on macos with java 17 from zulu.

First time the workspace is opened, the extension detects that lombok is used and propose to reload. The subsequent execution will start the language server correctly using the right Lombok jar from the dependencies:

message: 'Starting Java server with: Users/fortinma.sdkman/candidates/java/17.0.3-zulu/zulu-17.jdk/Contents/Home/bin/java ... -javaagent:/Users/fortinma/.m2/repository/org/projectlombok/lombok/1.18.24/lombok-1.18.24.jar

At the end of the project importation, the extension seems to pickup a wrong lombok jar and pops up a message saying that lombok version was changed from 1.18.24 to utils/1.18.12/lombok. The language server is then unable to start:

{
       message: 'Starting Java server with: ... -javaagent:/Users/fortinma/.m2/repository/org/projectlombok/lombok-utils/1.18.12/lombok-utils-1.18.12.jar <===== this is a wrong jar!!
       level: 'info',
       timestamp: '2022-07-05 21:21:57.084'
     }
     {
       message: 'Failed to find Premain-Class manifest attribute in Users/fortinma.m2/repository/org/projectlombok/lombok-utils/1.18.12/lombok-utils-1.18.12.jar\n',
       level: 'info',
       timestamp: '2022-07-05 21:21:57.239'
     }
     {
       message: 'Language Support for Java server encountered error and will shut down: undefined, Error: write EPIPE',
       level: 'error',
       timestamp: '2022-07-05 21:21:57.240'
     }

Following this error, the workspace is pretty much dead, and needs to be hard deleted.

The reason is that the regex used to find the lombok jar from the dependencies is too loose. /lombok-.*\.jar/ matches both lombok-1.18.24 and lombok-utils-1.18.12. Dont ask me why we are using lombok-utils, i have no idea. Will look into that later.

By having a more strict regex, ie /lombok-\d+.*\.jar/, we make sure we only matches lombok-111-222-333.jar, while not falling into really complicated semver matches (maybe that would be better?)

Tested in my environment and this works fine. Please point me to the right way to add tests for this, if needed.

Thanks!.

Signed-off-by: Mathieu Fortin <mathieu.m.fortin@autodesk.com>
@mathieufortin01
Copy link
Contributor Author

And thanks for the work on this extension! Ive seen it evolve since the last few years and this is for me the best java environment.

@testforstephen testforstephen self-requested a review July 6, 2022 03:09
Copy link
Collaborator

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This is a nice fix, thanks for contribution @mathieufortin01.

@testforstephen testforstephen added this to the End July 2022 milestone Jul 6, 2022
@testforstephen testforstephen merged commit 86c572d into redhat-developer:master Jul 6, 2022
@testforstephen
Copy link
Collaborator

@mathieufortin01 This fix will be included in tomorrow pre-release version. You could switch Java language support extension to pre-release version if you want to try it earlier.

@mathieufortin01 mathieufortin01 deleted the fixed-lombok-version-check branch July 6, 2022 11:11
@rgrunber rgrunber added the bug label Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants