incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1605846 - in /sling/trunk/contrib/crankstart: launcher/src/test/resources/launcher-test.crank.txt sling-extensions/src/main/java/org/apache/sling/crankstart/extensions/sling/InstallerResourceCommand.java
Date Thu, 26 Jun 2014 16:38:22 GMT
Author: bdelacretaz
Date: Thu Jun 26 16:38:21 2014
New Revision: 1605846

URL: http://svn.apache.org/r1605846
Log:
Use AutoClose stream

Modified:
    sling/trunk/contrib/crankstart/launcher/src/test/resources/launcher-test.crank.txt
    sling/trunk/contrib/crankstart/sling-extensions/src/main/java/org/apache/sling/crankstart/extensions/sling/InstallerResourceCommand.java

Modified: sling/trunk/contrib/crankstart/launcher/src/test/resources/launcher-test.crank.txt
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/launcher/src/test/resources/launcher-test.crank.txt?rev=1605846&r1=1605845&r2=1605846&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/launcher/src/test/resources/launcher-test.crank.txt (original)
+++ sling/trunk/contrib/crankstart/launcher/src/test/resources/launcher-test.crank.txt Thu
Jun 26 16:38:21 2014
@@ -40,6 +40,7 @@ bundle mvn:org.apache.sling/org.apache.s
 bundle mvn:org.apache.sling/org.apache.sling.commons.json/2.0.6
 bundle mvn:org.apache.sling/org.apache.sling.jcr.jcr-wrapper/2.0.0
 bundle mvn:org.apache.sling/org.apache.sling.crankstart.sling.extensions/0.0.1-SNAPSHOT
+bundle mvn:commons-io/commons-io/2.4
 
 # Now start our bundles
 start.all.bundles
@@ -72,4 +73,4 @@ test.system.property the.test.system.pro
 sling.installer.resource mvn:org.apache.sling/org.apache.sling.junit.core/1.0.8
   
 # Informative log  
-log felix http service should come up at http://localhost:${http.port}
\ No newline at end of file
+log felix http service should come up at http://localhost:${http.port}

Modified: sling/trunk/contrib/crankstart/sling-extensions/src/main/java/org/apache/sling/crankstart/extensions/sling/InstallerResourceCommand.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/sling-extensions/src/main/java/org/apache/sling/crankstart/extensions/sling/InstallerResourceCommand.java?rev=1605846&r1=1605845&r2=1605846&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/sling-extensions/src/main/java/org/apache/sling/crankstart/extensions/sling/InstallerResourceCommand.java
(original)
+++ sling/trunk/contrib/crankstart/sling-extensions/src/main/java/org/apache/sling/crankstart/extensions/sling/InstallerResourceCommand.java
Thu Jun 26 16:38:21 2014
@@ -19,6 +19,7 @@ package org.apache.sling.crankstart.exte
 import java.io.InputStream;
 import java.net.URL;
 
+import org.apache.commons.io.input.AutoCloseInputStream;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.crankstart.api.CrankstartCommand;
@@ -57,19 +58,15 @@ public class InstallerResourceCommand im
         if(ref == null) {
             throw new CrankstartException("Installer service not available, cannot register
resource (" + serviceClass + ")");
         }
-        InputStream stream = null;
         final OsgiInstaller installer = (OsgiInstaller)ctx.getService(ref);
         try {
-            stream = url.openStream();
+            final InputStream stream = new AutoCloseInputStream(url.openStream());
             final String digest = resourceRef;
             final InstallableResource r = new InstallableResource(resourceRef, stream, null,
digest, "file", 100);
             installer.registerResources("crankstart", new InstallableResource[] { r });
             log.info("Resource registered with Sling installer: {}", resourceRef);
         } finally {
             ctx.ungetService(ref);
-            if(stream != null) {
-                stream.close();
-            }
         }
     }
 }



Mime
View raw message