harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r979613 - in /harmony/enhanced/java/trunk/classlib/modules/nio_char/src: main/java/java/nio/charset/ test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ test/java/tests/api/java/nio/charset/
Date Tue, 27 Jul 2010 09:29:57 GMT
Author: tellison
Date: Tue Jul 27 09:29:56 2010
New Revision: 979613

URL: http://svn.apache.org/viewvc?rev=979613&view=rev
Log:
Revert r967069
"Apply patch for HARMONY-6594 ([classlib][nio_char] CharsetEncoder.flush(Bytebuffer) doesn't
follow the spec and RI's behavior)"
Causes test failures in LUNI module.

Modified:
    harmony/enhanced/java/trunk/classlib/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
    harmony/enhanced/java/trunk/classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java
    harmony/enhanced/java/trunk/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java?rev=979613&r1=979612&r2=979613&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
Tue Jul 27 09:29:56 2010
@@ -88,7 +88,7 @@ public abstract class CharsetEncoder {
     /*
      * internal status consts
      */
-    private static final int READY = 0;
+    private static final int INIT = 0;
 
     private static final int ONGOING = 1;
 
@@ -96,8 +96,6 @@ public abstract class CharsetEncoder {
 
     private static final int FLUSH = 3;
 
-    private static final int INIT = 4;
-
     // the Charset which creates this encoder
     private Charset cs;
 
@@ -113,9 +111,6 @@ public abstract class CharsetEncoder {
     // internal status
     private int status;
 
-    // internal status indicates encode(CharBuffer) operation is finished
-    private boolean finished;
-
     // action for malformed input
     private CodingErrorAction malformAction;
 
@@ -222,10 +217,10 @@ public abstract class CharsetEncoder {
 
     // implementation of canEncode
     private boolean implCanEncode(CharBuffer cb) {
-        if (status == FLUSH || status == INIT) {
-            status = READY;
+        if (status == FLUSH) {
+            status = INIT;
         }
-        if (status != READY) {
+        if (status != INIT) {
             // niochar.0B=Another encoding process is ongoing\!
             throw new IllegalStateException(Messages.getString("niochar.0B")); //$NON-NLS-1$
         }
@@ -352,8 +347,7 @@ public abstract class CharsetEncoder {
             }
             break;
         }
-        status = READY;
-        finished = true;
+        status = FLUSH;
         return output;
     }
 
@@ -444,12 +438,6 @@ public abstract class CharsetEncoder {
      */
     public final CoderResult encode(CharBuffer in, ByteBuffer out,
             boolean endOfInput) {
-        //If the previous step is encode(CharBuffer), then no more input is needed
-        // thus endOfInput should not be false
-        if (status == READY && finished && !endOfInput) {
-            throw new IllegalStateException();
-        }
-
         if ((status == FLUSH) || (!endOfInput && status == END)) {
             throw new IllegalStateException();
         }
@@ -565,7 +553,7 @@ public abstract class CharsetEncoder {
      *             for the last boolean parameter.
      */
     public final CoderResult flush(ByteBuffer out) {
-        if (status != END && status != READY) {
+        if (status != END && status != INIT) {
             throw new IllegalStateException();
         }
         CoderResult result = implFlush(out);

Modified: harmony/enhanced/java/trunk/classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java?rev=979613&r1=979612&r2=979613&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/nio_char/src/test/java/org/apache/harmony/nio_char/tests/java/nio/charset/ASCIICharsetEncoderTest.java
Tue Jul 27 09:29:56 2010
@@ -290,31 +290,20 @@ public class ASCIICharsetEncoderTest ext
     public void testInternalState_Flushed() {
         CharsetEncoder newEncoder = cs.newEncoder();
         
-        // init -> flushed
-		{
-			ByteBuffer out = ByteBuffer.allocate(0x10);
-			try {
-				newEncoder.flush(out);
-				fail("Should throw IllegalStateException");
-			} catch (IllegalStateException e) {
-				//expected
-			}
-
-		}
-
-        // reset - > flushed
+        //init -> flushed
+        {
+            ByteBuffer out = ByteBuffer.allocate(0x10);
+            newEncoder.flush(out);
+        }
+        
+        //reset - > flushed
         {
             newEncoder.reset();
             CharBuffer in = CharBuffer.wrap("A");
             ByteBuffer out = ByteBuffer.allocate(0x10);
             newEncoder.encode(in, out, true);
             newEncoder.reset();
-            try {
-                newEncoder.flush(out);
-				fail("Should throw IllegalStateException");
-            } catch (IllegalStateException e) {
-                //expected
-            }
+            newEncoder.flush(out);
         }
         
         //encoding - > flushed
@@ -432,14 +421,23 @@ public class ASCIICharsetEncoderTest ext
             CharBuffer in = CharBuffer.wrap("A");
             newEncoder.encode(in);
             ByteBuffer out = ByteBuffer.allocate(0x10);
-            newEncoder.encode(in, out, true);
+            try {
+                newEncoder.encode(in, out, true);
+                fail("Should throw IllegalStateException");
+            } catch (IllegalStateException e) {
+                // expected
+            }
         }
-
         //Encode -> Flushed
         {
             CharBuffer in = CharBuffer.wrap("A");
             ByteBuffer out = newEncoder.encode(in);
-            newEncoder.flush(out);
+            try {
+                newEncoder.flush(out);
+                fail("Should throw IllegalStateException");
+            } catch (IllegalStateException e) {
+                // expected
+            }
         }
         
         //Encode - > encode

Modified: harmony/enhanced/java/trunk/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java?rev=979613&r1=979612&r2=979613&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
Tue Jul 27 09:29:56 2010
@@ -296,7 +296,6 @@ public class CharsetEncoderTest extends 
 			encoder.flush(out);
 			fail("should throw IllegalStateException");
 		} catch (IllegalStateException e) {
-		    // Expected
 		}
 
 		// Illegal state: flush after encode with endOfInput is false
@@ -306,22 +305,8 @@ public class CharsetEncoderTest extends 
 			encoder.flush(out);
 			fail("should throw IllegalStateException");
 		} catch (IllegalStateException e) {
-		    // Expected
 		}
 	}
-	
-	public void testFlushAfterConstructing() {
-		ByteBuffer out = ByteBuffer.allocate(5);
-		
-		//Illegal state: flush after instance created
-		try {
-			encoder.flush(out);			
-			fail("should throw IllegalStateException");
-		} catch (IllegalStateException e) {
-			// Expected
-		}
-
-	}
 
 	// test illegal states for encode facade
 	public void testEncodeFacadeIllegalState() throws CharacterCodingException {



Mime
View raw message