Skip to content

Commit

Permalink
BundleComponent.isValidBundle() should no throw if reading manifest fail
Browse files Browse the repository at this point in the history
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
  • Loading branch information
laeubi committed Jun 21, 2024
1 parent 93f76cf commit 2773e25
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> manifest = getManifest();
return manifest != null && (manifest.get(Constants.BUNDLE_NAME) != null && manifest.get(Constants.BUNDLE_VERSION) != null);
public boolean isValidBundle() {
try {
Map<String, String> 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
Expand Down

0 comments on commit 2773e25

Please sign in to comment.