[jbossws-commits] JBossWS SVN: r7661 - common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Jun 19 07:03:31 EDT 2008


Author: darran.lofthouse at jboss.com
Date: 2008-06-19 07:03:31 -0400 (Thu, 19 Jun 2008)
New Revision: 7661

Modified:
   common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java
   common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/IOUtils.java
Log:
[JBPAPP-901] DOMUtils doesn't clear thread locals.

Modified: common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java
===================================================================
--- common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java	2008-06-19 10:58:36 UTC (rev 7660)
+++ common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/DOMUtils.java	2008-06-19 11:03:31 UTC (rev 7661)
@@ -113,6 +113,12 @@
       }
    };
 
+   public static void clearThreadLocals()
+   {
+      documentThreadLocal.remove();
+      builderThreadLocal.remove();
+   }
+
    // Hide the constructor
    private DOMUtils()
    {

Modified: common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/IOUtils.java
===================================================================
--- common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/IOUtils.java	2008-06-19 10:58:36 UTC (rev 7660)
+++ common/branches/jbossws-common-1.0.0.GA_CP/src/main/java/org/jboss/wsf/common/IOUtils.java	2008-06-19 11:03:31 UTC (rev 7661)
@@ -63,27 +63,47 @@
     */
    public static void copyStream(OutputStream outs, InputStream ins) throws IOException
    {
-      byte[] bytes = new byte[1024];
-      int r = ins.read(bytes);
-      while (r > 0)
+      try
       {
-         outs.write(bytes, 0, r);
-         r = ins.read(bytes);
+         byte[] bytes = new byte[1024];
+         int r = ins.read(bytes);
+         while (r > 0)
+         {
+            outs.write(bytes, 0, r);
+            r = ins.read(bytes);
+         }
       }
+      catch (IOException e)
+      {
+         throw e;
+      }
+      finally{
+         ins.close();
+      }
    }
 
    /** Copy the reader to the output stream
     */
    public static void copyReader(OutputStream outs, Reader reader) throws IOException
    {
-      OutputStreamWriter writer = new OutputStreamWriter(outs);
-      char[] bytes = new char[1024];
-      int r = reader.read(bytes);
-      while (r > 0)
+      try
       {
-         writer.write(bytes, 0, r);
-         r = reader.read(bytes);
+         OutputStreamWriter writer = new OutputStreamWriter(outs);
+         char[] bytes = new char[1024];
+         int r = reader.read(bytes);
+         while (r > 0)
+         {
+            writer.write(bytes, 0, r);
+            r = reader.read(bytes);
+         }
       }
+      catch (IOException e)
+      {
+         throw e;
+      }
+      finally{
+         reader.close();
+      }
    }
 
    public static byte[] convertToBytes(DataHandler dh)
@@ -106,17 +126,27 @@
     */
    public static InputStream transformReader(Reader reader) throws IOException
    {
-      int capacity = 1024;
-      char[] charBuffer = new char[capacity];
-      StringBuffer strBuffer = new StringBuffer(capacity);
+      try
+      {
+         int capacity = 1024;
+         char[] charBuffer = new char[capacity];
+         StringBuffer strBuffer = new StringBuffer(capacity);
 
-      int len = reader.read(charBuffer, 0, capacity);
-      while (len > 0)
+         int len = reader.read(charBuffer, 0, capacity);
+         while (len > 0)
+         {
+            strBuffer.append(charBuffer, 0, len);
+            len = reader.read(charBuffer, 0, capacity);
+         }
+         return new ByteArrayInputStream(strBuffer.toString().getBytes());
+      }
+      catch (IOException e)
       {
-         strBuffer.append(charBuffer, 0, len);
-         len = reader.read(charBuffer, 0, capacity);
+         throw e;
       }
-      return new ByteArrayInputStream(strBuffer.toString().getBytes());
+      finally{
+         reader.close();
+      }
    }
 
    public static File createTempDirectory() throws IOException




More information about the jbossws-commits mailing list