Skip to content

Skip contributed bundles that the server already ships - #4581

Open
uiradev wants to merge 1 commit into
redhat-developer:mainfrom
uiradev:skip-duplicate-contributed-bundles
Open

uiradev wants to merge 1 commit into
redhat-developer:mainfrom
uiradev:skip-duplicate-contributed-bundles

Conversation

@uiradev

@uiradev uiradev commented Nov 26, 2026

Copy link
Copy Markdown

Fixes #4580

When another extension contributes a jar through contributes.javaExtensions that JDT LS already ships at the same version, the server fails to install it with "A bundle is already installed" on every start. Test Runner for Java 0.47.0 does this with org.objectweb.asm_9.10.1.jar.

Changes

  • collectJavaExtensions (src/plugin.ts) leaves out a contributed jar when the server's plugins folder already has a jar with the same file name. p2 names jars <symbolicName>_<version>.jar, so the same name means the same bundle at the same version. A jar with a different version is still passed on.
  • Each skipped jar is logged once per session in the client log. collectJavaExtensions runs several times per start (for example, while waiting for workspace trust).
  • If the server folder doesn't exist (for example, when JDT LS is started separately), nothing is skipped.
  • getServerHome() (src/javaServerStarter.ts) holds the server location rule, so the launcher and the bundle filter use the same folder.
  • New test in test/standard-mode-suite/extension.test.ts.

Testing

  • npm run repo:check, npm run compile, npm run vscode:prepublish, vsce package and npm run eslint pass.
  • SKIP_COMMANDS_TEST=true npm test passes on macOS (Apple silicon): 14 lightweight and 55 standard tests passing, 2 pending.
  • Installed a darwin-arm64 build next to Test Runner for Java 0.47.0. The client log shows the skip, and the server log no longer has the "already installed" error.

Note: npm run eslint doesn't lint the .ts files in this repo. With ESLint 10.7.0, files: ["src/**"] doesn't match them, and they're reported as "File ignored because no matching configuration was supplied". I linted the changed files with an extra src/**/*.ts pattern, and they're clean.

When another extension contributes a jar through contributes.javaExtensions that JDT LS already ships at the same version, the server fails to install it with "A bundle is already installed" on every start. collectJavaExtensions now leaves out a contributed jar when the server's plugins folder already has a jar with the same file name, and logs each skipped jar once per session.

Fixes redhat-developer#4580

Signed-off-by: uiradev <83920075+uiradev@users.noreply.github.com>
@datho7561

Copy link
Copy Markdown
Contributor

Seems like a good idea; I'll do my best to take a quick look over this afternoon.

Even though this works around it, t'd be nice if vscode-java-test adapted to the fact they don't need to ship the bundle causing the problem; I'll follow up with them. We're due for a release so it'd be nice if they get everything in order before then.

Comment thread src/plugin.ts
export function collectJavaExtensions(extensions: readonly vscode.Extension<any>[], serverPluginsDir: string = path.join(getServerHome(), 'plugins')): string[] {
const result = [];
if (extensions && extensions.length) {
const serverJars = listJars(serverPluginsDir);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This works pretty good if an extension to vscode-java ships a jar that overlaps with the jars shipped by vscode-java itself, but what if two extensions ship the same jar?

I think it might be worth addressing this case in this PR. If you don't have time for that though, just let me know; I'm happy to merge the PR as is, since it addresses the linked bug.

@datho7561

Copy link
Copy Markdown
Contributor

Note: npm run eslint doesn't lint the .ts files in this repo. With ESLint 10.7.0, files: ["src/"] doesn't match them, and they're reported as "File ignored because no matching configuration was supplied". I linted the changed files with an extra src//*.ts pattern, and they're clean.

Thanks; I'll open a PR for that.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

"A bundle is already installed" error when an extension contributes a bundle that JDT LS already ships

2 participants