db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1148658 - /db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java
Date Wed, 20 Jul 2011 09:06:21 GMT
Author: kahatlen
Date: Wed Jul 20 09:06:20 2011
New Revision: 1148658

URL: http://svn.apache.org/viewvc?rev=1148658&view=rev
Log:
DERBY-5331: Incorrect use of CharsetEncoder in DDMWriter

Reset the encoder before use and flush when done.

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java?rev=1148658&r1=1148657&r2=1148658&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DDMWriter.java Wed Jul 20 09:06:20
2011
@@ -1208,7 +1208,11 @@ class DDMWriter
 
 		// encode the string
 		CharBuffer input = CharBuffer.wrap(s);
+		encoder.reset();
 		CoderResult res = encoder.encode(input, buffer, true);
+		if (res == CoderResult.UNDERFLOW) {
+			res = encoder.flush(buffer);
+		}
 		if (SanityManager.DEBUG) {
 			// UNDERFLOW is returned if the entire string was encoded, OVERFLOW
 			// is returned if the string was truncated at LONGVARCHAR_MAX_LEN
@@ -1235,7 +1239,11 @@ class DDMWriter
 	{
 		ensureLength(maxEncodedLength(s));
 		CharBuffer input = CharBuffer.wrap(s);
+		encoder.reset();
 		CoderResult res = encoder.encode(input, buffer, true);
+		if (res == CoderResult.UNDERFLOW) {
+			res = encoder.flush(buffer);
+		}
 		if (SanityManager.DEBUG) {
 			SanityManager.ASSERT(res == CoderResult.UNDERFLOW,
 								 "CharBuffer was not exhausted: res = " + res);



Mime
View raw message