Author: markt
Date: Thu Sep 3 19:44:27 2015
New Revision: 1701116
URL: http://svn.apache.org/r1701116
Log:
Use Charset rather than encoding name to create B2CConvertor
Modified:
tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
tomcat/trunk/java/org/apache/catalina/connector/InputBuffer.java
tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
tomcat/trunk/test/org/apache/tomcat/util/buf/TestB2CConverter.java
Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1701116&r1=1701115&r2=1701116&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Thu Sep
3 19:44:27 2015
@@ -1077,7 +1077,7 @@ public class CoyoteAdapter implements Ad
B2CConverter conv = request.getURIConverter();
try {
if (conv == null) {
- conv = new B2CConverter(enc, true);
+ conv = new B2CConverter(B2CConverter.getCharset(enc),
true);
request.setURIConverter(conv);
} else {
conv.recycle();
Modified: tomcat/trunk/java/org/apache/catalina/connector/InputBuffer.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/InputBuffer.java?rev=1701116&r1=1701115&r2=1701116&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/InputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/InputBuffer.java Thu Sep 3
19:44:27 2015
@@ -565,7 +565,7 @@ public class InputBuffer extends Reader
@Override
public B2CConverter run() throws IOException {
- return new B2CConverter(enc);
+ return new B2CConverter(charset);
}
}
);
@@ -576,7 +576,7 @@ public class InputBuffer extends Reader
}
}
} else {
- conv = new B2CConverter(enc);
+ conv = new B2CConverter(charset);
}
encoders.put(charset, conv);
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java?rev=1701116&r1=1701115&r2=1701116&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/B2CConverter.java Thu Sep 3
19:44:27 2015
@@ -97,12 +97,11 @@ public class B2CConverter {
*/
private final ByteBuffer leftovers;
- public B2CConverter(String encoding) throws IOException {
- this(encoding, false);
+ public B2CConverter(Charset charset) {
+ this(charset, false);
}
- public B2CConverter(String encoding, boolean replaceOnError)
- throws IOException {
+ public B2CConverter(Charset charset, boolean replaceOnError) {
byte[] left = new byte[LEFTOVER_SIZE];
leftovers = ByteBuffer.wrap(left);
CodingErrorAction action;
@@ -111,7 +110,6 @@ public class B2CConverter {
} else {
action = CodingErrorAction.REPORT;
}
- Charset charset = getCharset(encoding);
// Special case. Use the Apache Harmony based UTF-8 decoder because it
// - a) rejects invalid sequences that the JVM decoder does not
// - b) fails faster for some invalid sequences
Modified: tomcat/trunk/test/org/apache/tomcat/util/buf/TestB2CConverter.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/buf/TestB2CConverter.java?rev=1701116&r1=1701115&r2=1701116&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/buf/TestB2CConverter.java
(original)
+++ tomcat/trunk/test/org/apache/tomcat/util/buf/TestB2CConverter.java Thu Sep
3 19:44:27 2015
@@ -18,6 +18,7 @@ package org.apache.tomcat.util.buf;
import java.nio.charset.Charset;
import java.nio.charset.MalformedInputException;
+import java.nio.charset.StandardCharsets;
import java.util.Locale;
import org.junit.Assert;
@@ -48,7 +49,7 @@ public class TestB2CConverter {
}
private void testMessages(int msgCount) throws Exception {
- B2CConverter conv = new B2CConverter("UTF-16");
+ B2CConverter conv = new B2CConverter(StandardCharsets.UTF_16);
ByteChunk bc = new ByteChunk();
CharChunk cc = new CharChunk(32);
@@ -96,7 +97,7 @@ public class TestB2CConverter {
@Test(expected=MalformedInputException.class)
public void testBug54602a() throws Exception {
// Check invalid input is rejected straight away
- B2CConverter conv = new B2CConverter("UTF-8");
+ B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);
ByteChunk bc = new ByteChunk();
CharChunk cc = new CharChunk();
@@ -109,7 +110,7 @@ public class TestB2CConverter {
@Test(expected=MalformedInputException.class)
public void testBug54602b() throws Exception {
// Check partial input is rejected
- B2CConverter conv = new B2CConverter("UTF-8");
+ B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);
ByteChunk bc = new ByteChunk();
CharChunk cc = new CharChunk();
@@ -122,7 +123,7 @@ public class TestB2CConverter {
@Test
public void testBug54602c() throws Exception {
// Check partial input is rejected once it is known to be all available
- B2CConverter conv = new B2CConverter("UTF-8");
+ B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);
ByteChunk bc = new ByteChunk();
CharChunk cc = new CharChunk();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]