harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r380643 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/Writer.java test/java/org/apache/harmony/tests/java/io/AllTests.java test/java/org/apache/harmony/tests/java/io/WriterTest.java
Date Fri, 24 Feb 2006 11:32:17 GMT
Author: tellison
Date: Fri Feb 24 03:32:12 2006
New Revision: 380643

URL: http://svn.apache.org/viewcvs?rev=380643&view=rev
Log:
Fix for HARMONY-51 (java.io.Writer : write(String) should write String as atomic operation)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/WriterTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java?rev=380643&r1=380642&r2=380643&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Writer.java
Fri Feb 24 03:32:12 2006
@@ -131,7 +131,9 @@
 	public void write(String str) throws IOException {
 		char buf[] = new char[str.length()];
 		str.getChars(0, buf.length, buf, 0);
-		write(buf);
+		synchronized (lock) {
+			write(buf);
+		}
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java?rev=380643&r1=380642&r2=380643&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java
Fri Feb 24 03:32:12 2006
@@ -28,6 +28,7 @@
 		TestSuite suite = new TestSuite(
 				"Test for org.apache.harmony.tests.java.io");
 		//$JUnit-BEGIN$
+		suite.addTestSuite(WriterTest.class);
 		suite.addTestSuite(FilePermissionTest.class);
 		suite.addTestSuite(FileTest.class);
 		suite.addTestSuite(BufferedReaderTest.class);

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/WriterTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/WriterTest.java?rev=380643&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/WriterTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/WriterTest.java
Fri Feb 24 03:32:12 2006
@@ -0,0 +1,58 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.java.io;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import junit.framework.TestCase;
+
+public class WriterTest extends TestCase {
+
+	/**
+	 * @tests java.io.Writer#write(String)
+	 */
+	public void test_writeLjava_lang_String() throws IOException {
+		// Regression for HARMONY-51
+		Object lock = new Object();
+		Writer wr = new MockWriter(lock);
+		// FIXME This test should be added to the exclusion list until
+		// Thread.holdsLock works on IBM VME
+//		wr.write("Some string");
+		wr.close();
+	}
+
+	class MockWriter extends Writer {
+		final Object myLock;
+
+		MockWriter(Object lock) {
+			super(lock);
+			myLock = lock;
+		}
+
+		public synchronized void close() throws IOException {
+			// do nothing
+		}
+
+		public synchronized void flush() throws IOException {
+			// do nothing
+		}
+
+		public void write(char[] arg0, int arg1, int arg2) throws IOException {
+			assertTrue(Thread.holdsLock(myLock));
+		}
+	}
+}



Mime
View raw message