Skip to content

Commit b9e07b1

Browse files
committed
Manifest: split out JarURLConnection logic
This will be useful momentarily.
1 parent aeccb57 commit b9e07b1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/java/org/scijava/util/Manifest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
package org.scijava.util;
3333

34+
import java.io.File;
35+
import java.io.FileNotFoundException;
3436
import java.io.IOException;
3537
import java.net.JarURLConnection;
3638
import java.net.URL;
@@ -134,13 +136,16 @@ public Map<Object, Object> getAll() {
134136
/** Gets the JAR manifest associated with the given class. */
135137
public static Manifest getManifest(final Class<?> c) {
136138
try {
137-
// try to grab manifest from the JAR
138-
final URL location = new URL("jar:" + ClassUtils.getLocation(c) + "!/");
139-
return new Manifest(((JarURLConnection)location.openConnection()).getManifest());
139+
return getManifest(new URL("jar:" + ClassUtils.getLocation(c) + "!/"));
140140
}
141141
catch (final IOException e) {
142142
return null;
143143
}
144144
}
145145

146+
private static Manifest getManifest(final URL jarURL) throws IOException {
147+
final JarURLConnection conn = (JarURLConnection) jarURL.openConnection();
148+
return new Manifest(conn.getManifest());
149+
}
150+
146151
}

0 commit comments

Comments
 (0)