incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1555017 - /sling/trunk/bundles/extensions/healthcheck/webconsole/src/main/java/org/apache/sling/hc/webconsole/impl/HealthCheckWebconsolePlugin.java
Date Fri, 03 Jan 2014 06:23:20 GMT
Author: cziegeler
Date: Fri Jan  3 06:23:20 2014
New Revision: 1555017

URL: http://svn.apache.org/r1555017
Log:
SLING-3278 : Provide a HealthCheckExecutor service. Clean up web console plugin code

Modified:
    sling/trunk/bundles/extensions/healthcheck/webconsole/src/main/java/org/apache/sling/hc/webconsole/impl/HealthCheckWebconsolePlugin.java

Modified: sling/trunk/bundles/extensions/healthcheck/webconsole/src/main/java/org/apache/sling/hc/webconsole/impl/HealthCheckWebconsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/webconsole/src/main/java/org/apache/sling/hc/webconsole/impl/HealthCheckWebconsolePlugin.java?rev=1555017&r1=1555016&r2=1555017&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/healthcheck/webconsole/src/main/java/org/apache/sling/hc/webconsole/impl/HealthCheckWebconsolePlugin.java
(original)
+++ sling/trunk/bundles/extensions/healthcheck/webconsole/src/main/java/org/apache/sling/hc/webconsole/impl/HealthCheckWebconsolePlugin.java
Fri Jan  3 06:23:20 2014
@@ -19,6 +19,7 @@ package org.apache.sling.hc.webconsole.i
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.util.Collection;
 
@@ -83,18 +84,27 @@ public class HealthCheckWebconsolePlugin
     private boolean getStaticResource(final HttpServletRequest req, final HttpServletResponse
resp)
    throws ServletException, IOException {
         final String pathInfo = req.getPathInfo();
-        if(pathInfo!= null && pathInfo.contains("res/ui")) {
+        if (pathInfo!= null && pathInfo.contains("res/ui")) {
             final String prefix = "/" + LABEL;
             final InputStream is = getClass().getResourceAsStream(pathInfo.substring(prefix.length()));
-            if(is == null) {
+            if (is == null) {
                 resp.sendError(HttpServletResponse.SC_NOT_FOUND, pathInfo);
+            } else {
+                final OutputStream os = resp.getOutputStream();
+                try {
+                    final byte [] buffer = new byte[16384];
+                    int n=0;
+                    while( (n = is.read(buffer, 0, buffer.length)) > 0) {
+                        os.write(buffer, 0, n);
+                    }
+                } finally {
+                    try {
+                        is.close();
+                    } catch ( final IOException ignore ) {
+                        // ignore
+                    }
+                }
             }
-            final byte [] buffer = new byte[16384];
-            int n=0;
-            while( (n = is.read(buffer, 0, buffer.length)) > 0) {
-                resp.getOutputStream().write(buffer, 0, n);
-            }
-            resp.getOutputStream().flush();
             return true;
         }
         return false;



Mime
View raw message