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

Suppress try-with-resources warning #499

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2017 Tasktop Technologies and others.
* Copyright (c) 2009, 2024 Tasktop Technologies and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -59,7 +59,8 @@ private void processDiscoveryCoreBundle(IExtensionRegistry registry) {
// extension point itself
try {
Bundle bundle = Platform.getBundle("org.eclipse.equinox.p2.discovery.compatibility"); //$NON-NLS-1$
IContributor contributor = new RegistryContributor(bundle.getSymbolicName(), bundle.getSymbolicName(), null, null);
IContributor contributor = new RegistryContributor(bundle.getSymbolicName(), bundle.getSymbolicName(), null,
null);

try (InputStream inputStream = bundle.getEntry("plugin.xml").openStream()) { //$NON-NLS-1$
registry.addContribution(inputStream, contributor, false, bundle.getSymbolicName(), null, token);
Expand All @@ -77,12 +78,16 @@ private void processBundles(IExtensionRegistry registry) {
try {
processBundle(registry, bundleFile.getValue(), bundleFile.getKey());
} catch (Exception e) {
LogHelper.log(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.DiscoveryRegistryStrategy_cannot_load_bundle, new Object[] {bundleFile.getKey().getName(), bundleFile.getValue().getLocation(), e.getMessage()}), e));
LogHelper.log(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN,
NLS.bind(Messages.DiscoveryRegistryStrategy_cannot_load_bundle, new Object[] {
bundleFile.getKey().getName(), bundleFile.getValue().getLocation(), e.getMessage() }),
e));
}
}
}

private void processBundle(IExtensionRegistry registry, Directory.Entry entry, File bundleFile) throws IOException {
@SuppressWarnings("resource")
JarFile jarFile = new JarFile(bundleFile);
jars.add(jarFile);

Expand Down Expand Up @@ -159,8 +164,7 @@ public void onStop(IExtensionRegistry registry) {
/**
* get the jar file that corresponds to the given contributor.
*
* @throws IllegalArgumentException
* if the given contributor is unknown
* @throws IllegalArgumentException if the given contributor is unknown
*/
public File getJarFile(IContributor contributor) {
File file = contributorToJarFile.get(contributor);
Expand All @@ -173,8 +177,7 @@ public File getJarFile(IContributor contributor) {
/**
* get the directory entry that corresponds to the given contributor.
*
* @throws IllegalArgumentException
* if the given contributor is unknown
* @throws IllegalArgumentException if the given contributor is unknown
*/
public Entry getDirectoryEntry(IContributor contributor) {
Entry entry = contributorToDirectoryEntry.get(contributor);
Expand Down
Loading