Author: jfrederic.clere(a)jboss.com
Date: 2009-08-04 12:33:39 -0400 (Tue, 04 Aug 2009)
New Revision: 1140
Modified:
branches/2.1.x/java/org/apache/tomcat/util/buf/C2BConverter.java
Log:
Fix for JBAS-6442.
Modified: branches/2.1.x/java/org/apache/tomcat/util/buf/C2BConverter.java
===================================================================
--- branches/2.1.x/java/org/apache/tomcat/util/buf/C2BConverter.java 2009-07-20 16:46:09
UTC (rev 1139)
+++ branches/2.1.x/java/org/apache/tomcat/util/buf/C2BConverter.java 2009-08-04 16:33:39
UTC (rev 1140)
@@ -25,6 +25,7 @@
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.UnsupportedCharsetException;
+import java.nio.charset.CodingErrorAction;
/**
* NIO based character encoder.
@@ -46,7 +47,10 @@
public C2BConverter(String charset)
throws IOException {
try {
+ byte[] newReplacement = { (byte)'?' };
encoder = Charset.forName(charset).newEncoder();
+ encoder = encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
+ encoder = encoder.replaceWith(newReplacement);
} catch (UnsupportedCharsetException e) {
throw new UnsupportedEncodingException(charset);
}
Show replies by date