Skip to content

Commit

Permalink
avoid try-with-resource compiler warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Bananeweizen authored and akurtakov committed Dec 5, 2024
1 parent 49fe9a3 commit 23f0197
Showing 1 changed file with 18 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Code 9 - initial API and implementation
* IBM - ongoing development
* SAP AG - make optional dependencies non-greedy by default; allow setting greedy through directive (bug 247099)
* Red Hat Inc. - Bug 460967
* Red Hat Inc. - Bug 460967
* Christoph Läubrich - Bug 574952 p2 should distinguish between "product plugins" and "configuration plugins" (gently sponsored by Compart AG)
******************************************************************************/
package org.eclipse.tycho.p2maven.tmp;
Expand Down Expand Up @@ -121,15 +121,15 @@ public class BundlesAction extends AbstractPublisherAction {
/**
* A capability name in the {@link PublisherHelper#NAMESPACE_ECLIPSE_TYPE}
* namespace representing and OSGi bundle resource
*
*
* @see IProvidedCapability#getName()
*/
public static final String TYPE_ECLIPSE_BUNDLE = "bundle"; //$NON-NLS-1$

/**
* A capability name in the {@link PublisherHelper#NAMESPACE_ECLIPSE_TYPE}
* namespace representing a source bundle
*
*
* @see IProvidedCapability#getName()
*/
public static final String TYPE_ECLIPSE_SOURCE = "source"; //$NON-NLS-1$
Expand Down Expand Up @@ -159,7 +159,7 @@ public class BundlesAction extends AbstractPublisherAction {
/**
* Manifest header directive for specifying how optional runtime requirements
* shall be handled during installation.
*
*
* @see #INSTALLATION_GREEDY
*/
public static final String INSTALLATION_DIRECTIVE = "x-installation"; //$NON-NLS-1$
Expand Down Expand Up @@ -541,13 +541,13 @@ private IInstallableUnitFragment createHostLocalizationFragment(IInstallableUnit

/*
* @param hostId
*
*
* @param bd
*
*
* @param locale
*
*
* @param localizedStrings
*
*
* @return installableUnitFragment
*/
private static IInstallableUnitFragment createLocalizationFragmentOfHost(BundleDescription bd, String hostId,
Expand Down Expand Up @@ -876,35 +876,20 @@ public static Dictionary<String, String> basicLoadManifestIgnoringExceptions(Fil

public static Dictionary<String, String> basicLoadManifest(File bundleLocation)
throws IOException, BundleException {
InputStream manifestStream = null;
ZipFile jarFile = null;
if ("jar".equalsIgnoreCase(IPath.fromOSString(bundleLocation.getName()).getFileExtension()) && bundleLocation.isFile()) { //$NON-NLS-1$
jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
ZipEntry manifestEntry = jarFile.getEntry(JarFile.MANIFEST_NAME);
if (manifestEntry != null) {
manifestStream = jarFile.getInputStream(manifestEntry);
try (ZipFile jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ)) {
ZipEntry manifestEntry = jarFile.getEntry(JarFile.MANIFEST_NAME);
if (manifestEntry != null) {
return parseBundleManifestIntoModifyableDictionaryWithCaseInsensitiveKeys(jarFile.getInputStream(manifestEntry));
}
}
} else {
File manifestFile = new File(bundleLocation, JarFile.MANIFEST_NAME);
if (manifestFile.exists()) {
manifestStream = new BufferedInputStream(new FileInputStream(manifestFile));
}
}
try {
if (manifestStream != null) {
return parseBundleManifestIntoModifyableDictionaryWithCaseInsensitiveKeys(manifestStream);
}
} finally {
try {
if (jarFile != null)
jarFile.close();
} catch (IOException e2) {
// Ignore
return parseBundleManifestIntoModifyableDictionaryWithCaseInsensitiveKeys(new BufferedInputStream(new FileInputStream(manifestFile)));
}
}

return null;

}

private static Dictionary<String, String> parseBundleManifestIntoModifyableDictionaryWithCaseInsensitiveKeys(
Expand Down Expand Up @@ -1019,13 +1004,13 @@ else if (new File(location, "plugin.xml").exists() || new File(location, "fragme

/**
* Publishes bundle IUs to the p2 metadata and artifact repositories.
*
*
* @param bundleDescriptions Equinox framework descriptions of the bundles to
* publish.
* @param result Used to attach status for the publication
* operation.
* @param monitor Used to fire progress events.
*
*
* @deprecated Use
* {@link #generateBundleIUs(BundleDescription[] bundleDescriptions, IPublisherInfo info, IPublisherResult result, IProgressMonitor monitor)}
* with {@link IPublisherInfo} set to <code>null</code>
Expand All @@ -1038,10 +1023,10 @@ protected void generateBundleIUs(BundleDescription[] bundleDescriptions, IPublis

/**
* Publishes bundle IUs to the p2 metadata and artifact repositories.
*
*
* @param bundleDescriptions Equinox framework descriptions of the bundles to
* publish.
* @param publisherInfo Configuration and publication advice information.
* @param publisherInfo Configuration and publication advice information.
* @param result Used to attach status for the publication
* operation.
* @param monitor Used to fire progress events.
Expand Down

0 comments on commit 23f0197

Please sign in to comment.