From 2773e25b958dc485135ef893124344f2f69c9fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sun, 16 Jun 2024 16:04:59 +0200 Subject: [PATCH] BundleComponent.isValidBundle() should no throw if reading manifest fail Currently BundleComponent.isValidBundle() is used to check if a bundle is valid and should be considered for the baseline. If the location points to something that chase no manifest at all (or an invalid manifest) this currently an exception even though the API doc clearly states that "Validity is determined via the existence of a readable manifest file" This now adds two checks 1) the location points to a file that exits and is larger than zero bytes 2) parsing the manifest from the location do not throw an exception --- .../api/tools/internal/model/BundleComponent.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java index cc1b292b9e..56a0b06467 100644 --- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java +++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/BundleComponent.java @@ -268,9 +268,15 @@ protected synchronized void doManifestCompaction() { * * @return true if the bundle at the given location is valid false otherwise */ - public boolean isValidBundle() throws CoreException { - Map manifest = getManifest(); - return manifest != null && (manifest.get(Constants.BUNDLE_NAME) != null && manifest.get(Constants.BUNDLE_VERSION) != null); + public boolean isValidBundle() { + try { + Map manifest = getManifest(); + return manifest != null + && (manifest.get(Constants.BUNDLE_NAME) != null && manifest.get(Constants.BUNDLE_VERSION) != null); + } catch (CoreException e) { + // if loading the manifest fails, this is NOT a valid bundle obviously... + } + return false; } @Override