Skip to content

Commit

Permalink
Suppress try-with-resources warning
Browse files Browse the repository at this point in the history
  • Loading branch information
akurtakov committed Apr 17, 2024
1 parent 5d95db1 commit b7d3b57
Showing 1 changed file with 10 additions and 7 deletions.
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

0 comments on commit b7d3b57

Please sign in to comment.