Skip to content

Commit

Permalink
Manifest: add some defensive programming
Browse files Browse the repository at this point in the history
This guards against the wrapped manifest being null, as well as the
wrapped manifest's main attributes being null for some reason.

Intended to address (the symptom, at least) of Fiji bug 889:

    http://fiji.sc/bugzilla/show_bug.cgi?id=889
  • Loading branch information
ctrueden committed Aug 10, 2014
1 parent 6410909 commit 8648ed5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/org/scijava/util/Manifest.java
Expand Up @@ -36,6 +36,7 @@
import java.net.URL;
import java.util.Collections;
import java.util.Map;
import java.util.jar.Attributes;

/**
* Helper class for working with JAR manifests.
Expand Down Expand Up @@ -115,11 +116,17 @@ public String getSpecificationVersion() {
}

public String get(final String key) {
return manifest.getMainAttributes().getValue(key);
if (manifest == null) return null;
final Attributes mainAttrs = manifest.getMainAttributes();
if (mainAttrs == null) return null;
return mainAttrs.getValue(key);
}

public Map<Object, Object> getAll() {
return Collections.unmodifiableMap(manifest.getMainAttributes());
if (manifest == null) return null;
final Attributes mainAttrs = manifest.getMainAttributes();
if (mainAttrs == null) return null;
return Collections.unmodifiableMap(mainAttrs);
}

// -- Utility methods --
Expand Down

0 comments on commit 8648ed5

Please sign in to comment.