Author: veithen
Date: Sat Apr 20 09:03:17 2013
New Revision: 1470129

URL: http://svn.apache.org/r1470129
Log:
AXIS2-5511: Merged r1305728 to the 1.6 branch.

Added:
    
axis/axis2/java/core/branches/1_6/modules/kernel/test/org/apache/axis2/util/XMLPrettyPrinterTest.java
      - copied unchanged from r1305728, 
axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/util/XMLPrettyPrinterTest.java
Modified:
    axis/axis2/java/core/branches/1_6/   (props changed)
    
axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java
    axis/axis2/java/core/branches/1_6/modules/saaj/   (props changed)

Propchange: axis/axis2/java/core/branches/1_6/
------------------------------------------------------------------------------
  Merged /axis/axis2/java/core/trunk:r1305728

Modified: 
axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java?rev=1470129&r1=1470128&r2=1470129&view=diff
==============================================================================
--- 
axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java
 (original)
+++ 
axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/util/XMLPrettyPrinter.java
 Sat Apr 20 09:03:17 2013
@@ -58,7 +58,9 @@ public class XMLPrettyPrinter {
         FileOutputStream outputStream = null;
         byte[] byteArray = null;
         try {
-            byteArray = IOUtils.getStreamAsByteArray(new 
FileInputStream(file));
+            FileInputStream fin = new FileInputStream(file);
+            byteArray = IOUtils.getStreamAsByteArray(fin);
+            fin.close();
             inputStream = new ByteArrayInputStream(byteArray);
             outputStream = new FileOutputStream(file);
 
@@ -88,6 +90,18 @@ public class XMLPrettyPrinter {
             log.debug("Pretty printed file : " + file);
         } catch (Throwable t) {
             log.debug("Exception occurred while trying to pretty print file " 
+ file, t);
+            
+            /* if outputStream is already created, close them, because we are 
going reassign
+             * different value to that. It will leak the file handle 
(specially in windows, since
+             * deleting is going to be an issue)
+             */
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (IOException e) {
+                    log.debug(e.getMessage(), e);
+                }
+            }
             try {
                 if (byteArray != null) {
                     outputStream = new FileOutputStream(file);

Propchange: axis/axis2/java/core/branches/1_6/modules/saaj/
------------------------------------------------------------------------------
  Merged /axis/axis2/java/core/trunk/modules/saaj:r1305728


Reply via email to