Skip to content

Fix the conflict of bundle when updating.#385

Closed
yaohaizh wants to merge 1 commit into
eclipse-jdtls:masterfrom
yaohaizh:bundle_update
Closed

Fix the conflict of bundle when updating.#385
yaohaizh wants to merge 1 commit into
eclipse-jdtls:masterfrom
yaohaizh:bundle_update

Conversation

@yaohaizh

@yaohaizh yaohaizh commented Oct 13, 2017

Copy link
Copy Markdown
Contributor

Signed-off-by: Yaohai Zheng yaozheng@microsoft.com

Fix the issue: microsoft/vscode-java-debug#54

In this change, it makes sure the extension symbolic name is unique and doesn't support multiple version of bundles. These limitation should not be problems for jdt.ls extensions.
@fbricon @gorkem @tsmaeder

@yaohaizh yaohaizh changed the title Fix the issue conflict of bundle when updating. Fix the conflict of bundle when updating. Oct 13, 2017

private static BundleInfo getBundleInfo(String bundleLocation) throws IOException {
JarFile jarFile = new JarFile(bundleLocation);
Manifest manifest = jarFile.getManifest();

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.

might want to check if manifest != null

}

return new BundleInfo(bundleVersion, symbolicName);
}

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.

private static BundleInfo getBundleInfo(String bundleLocation) throws IOException {
	try (JarFile jarFile = new JarFile(bundleLocation)){
		Manifest manifest = jarFile.getManifest();
		if (manifest != null) {
			Attributes mainAttributes = manifest.getMainAttributes();
			String bundleVersion = mainAttributes.getValue(Constants.BUNDLE_VERSION);
			String symbolicName = mainAttributes.getValue(Constants.BUNDLE_SYMBOLICNAME);
			if (StringUtils.isNotBlank(symbolicName) && symbolicName.indexOf(";") >= 0) {
				symbolicName = symbolicName.substring(0, symbolicName.indexOf(";"));
			}							
			return new BundleInfo(bundleVersion, symbolicName);
		}
	}
	return null;
}

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.

alternatively, throw IOException instead of returning null


Bundle bundle = context.getBundle(location);
boolean needInstall = true;
BundleInfo bundleInfo = getBundleInfo(bundleLocation);

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.

check if bundleInfo is null?

@fbricon

fbricon commented Oct 13, 2017

Copy link
Copy Markdown
Contributor

Other than making getBundleInfo(...) more robust, this PR looks good. We'll include it in the next release.

@fbricon fbricon added this to the Mid October 2017 milestone Oct 13, 2017
Signed-off-by: Yaohai Zheng <yaozheng@microsoft.com>
@yaohaizh

Copy link
Copy Markdown
Contributor Author

Update the changes.

@fbricon

fbricon commented Oct 16, 2017

Copy link
Copy Markdown
Contributor

Merged as 7dc20a2 (after adding a null check on bundle version)

@fbricon fbricon closed this Oct 16, 2017
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.

2 participants