Author: juanpablo
Date: Fri Dec 27 10:23:04 2013
New Revision: 1553661

URL: http://svn.apache.org/r1553661
Log:
(missing from yesterday's commit) sonar: Bad practice - Method may fail to 
close stream

Modified:
    
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/auth/AuthenticationManager.java

Modified: 
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
URL: 
http://svn.apache.org/viewvc/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/auth/AuthenticationManager.java?rev=1553661&r1=1553660&r2=1553661&view=diff
==============================================================================
--- 
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
 (original)
+++ 
jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
 Fri Dec 27 10:23:04 2013
@@ -633,11 +633,12 @@ public class AuthenticationManager {
         if( engine.getServletContext() != null )
         {
                OutputStream os = null;
+               InputStream is = null;
             try
             {
                 //  create a tmp file of the policy loaded as an InputStream 
and return the URL to it
                 //  
-                InputStream is = 
AuthenticationManager.class.getResourceAsStream( "/" + name );
+                is = AuthenticationManager.class.getResourceAsStream( "/" + 
name );
                 File tmpFile = File.createTempFile( "temp." + name, "" );
                 tmpFile.deleteOnExit();
 
@@ -645,7 +646,7 @@ public class AuthenticationManager {
 
                 byte[] buff = new byte[1024];
 
-                while (is.read(buff) != -1)
+                while( is.read(buff) != -1 )
                 {
                     os.write(buff);
                 }
@@ -655,14 +656,15 @@ public class AuthenticationManager {
             catch( MalformedURLException e )
             {
                 // This should never happen unless I screw up
-                log.fatal("Your code is b0rked.  You are a bad person.");
+                log.fatal( "Your code is b0rked.  You are a bad person.", e );
             }
             catch (IOException e)
             {
-               log.error("failed to load security policy from file " + name + 
",stacktrace follows", e);
+               log.error( "failed to load security policy from file " + name + 
",stacktrace follows", e );
             }
             finally 
             {
+               IOUtils.closeQuietly( is );
                IOUtils.closeQuietly( os );
             }
         }


Reply via email to