Fix NPEs and make service execution more robust.
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1060274 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/installer/factories/deploypck/impl/DeploymentPackageInstaller.java b/src/main/java/org/apache/sling/installer/factories/deploypck/impl/DeploymentPackageInstaller.java
index fa0337f..934b18f 100644
--- a/src/main/java/org/apache/sling/installer/factories/deploypck/impl/DeploymentPackageInstaller.java
+++ b/src/main/java/org/apache/sling/installer/factories/deploypck/impl/DeploymentPackageInstaller.java
@@ -91,29 +91,30 @@
private Manifest getManifest(final InputStream ins) throws IOException {
Manifest result = null;
- JarInputStream jis = null;
- try {
- jis = new JarInputStream(ins);
- result= jis.getManifest();
+ if ( ins != null ) {
+ JarInputStream jis = null;
+ try {
+ jis = new JarInputStream(ins);
+ result= jis.getManifest();
- } finally {
+ } finally {
- // close the jar stream or the inputstream, if the jar
- // stream is set, we don't need to close the input stream
- // since closing the jar stream closes the input stream
- if (jis != null) {
- try {
- jis.close();
- } catch (IOException ignore) {
- }
- } else {
- try {
- ins.close();
- } catch (IOException ignore) {
+ // close the jar stream or the inputstream, if the jar
+ // stream is set, we don't need to close the input stream
+ // since closing the jar stream closes the input stream
+ if (jis != null) {
+ try {
+ jis.close();
+ } catch (IOException ignore) {
+ }
+ } else {
+ try {
+ ins.close();
+ } catch (IOException ignore) {
+ }
}
}
}
-
return result;
}