harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r597498 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java
Date Thu, 22 Nov 2007 21:25:24 GMT
Author: tellison
Date: Thu Nov 22 13:25:21 2007
New Revision: 597498

URL: http://svn.apache.org/viewvc?rev=597498&view=rev
Log:
Part of HARMONY-5077 ([classlib][io] a stress test org.apache.harmony.test.stress.api.java.io.stress.readers.StringReader.StringReaderWriterStressTest.testManyStreams
deadlocks)
Don't need to synchronize on calls to StringBuffer that are already synchronized methods.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java?rev=597498&r1=597497&r2=597498&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java Thu
Nov 22 13:25:21 2007
@@ -84,9 +84,7 @@
      * @return this StringWriters local StringBuffer.
      */
     public StringBuffer getBuffer() {
-        synchronized (lock) {
-            return buf;
-        }
+        return buf;
     }
 
     /**
@@ -98,9 +96,7 @@
      */
     @Override
     public String toString() {
-        synchronized (lock) {
-            return buf.toString();
-        }
+        return buf.toString();
     }
 
     /**
@@ -124,9 +120,10 @@
                 || count > cbuf.length - offset) {
             throw new IndexOutOfBoundsException();
         }
-        synchronized (lock) {
-            this.buf.append(cbuf, offset, count);
+        if (count == 0) {
+            return;
         }
+        buf.append(cbuf, offset, count);
     }
 
     /**
@@ -139,9 +136,7 @@
      */
     @Override
     public void write(int oneChar) {
-        synchronized (lock) {
-            buf.append((char) oneChar);
-        }
+        buf.append((char) oneChar);
     }
 
     /**
@@ -153,9 +148,7 @@
      */
     @Override
     public void write(String str) {
-        synchronized (lock) {
-            buf.append(str);
-        }
+        buf.append(str);
     }
 
     /**
@@ -176,9 +169,7 @@
     @Override
     public void write(String str, int offset, int count) {
         String sub = str.substring(offset, offset + count);
-        synchronized (lock) {
-            buf.append(sub);
-        }
+        buf.append(sub);
     }
 
     /**
@@ -209,9 +200,9 @@
     @Override
     public StringWriter append(CharSequence csq) {
         if (null == csq) {
-            append(TOKEN_NULL, 0, TOKEN_NULL.length());
+            write(TOKEN_NULL);
         } else {
-            append(csq, 0, csq.length());
+            write(csq.toString());
         }
         return this;
     }



Mime
View raw message