You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/06/26 09:44:16 UTC

[tomcat] 02/05: Use the previous decode call in the old default for now

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 03b51908102e9fa42739e680f2b785b9b2b84f78
Author: remm <re...@apache.org>
AuthorDate: Fri Jun 23 09:43:40 2023 +0200

    Use the previous decode call in the old default for now
    
    Just in case it makes a performance difference (the JVM code is very
    different).
---
 java/org/apache/tomcat/util/buf/ByteChunk.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/util/buf/ByteChunk.java b/java/org/apache/tomcat/util/buf/ByteChunk.java
index ef02a4f86b..58b6a57794 100644
--- a/java/org/apache/tomcat/util/buf/ByteChunk.java
+++ b/java/org/apache/tomcat/util/buf/ByteChunk.java
@@ -584,8 +584,13 @@ public final class ByteChunk extends AbstractChunk {
         // new String(byte[], int, int, Charset) takes a defensive copy of the
         // entire byte array. This is expensive if only a small subset of the
         // bytes will be used. The code below is from Apache Harmony.
-        CharBuffer cb = charset.newDecoder().onMalformedInput(malformedInputAction)
-                .onUnmappableCharacter(unmappableCharacterAction).decode(ByteBuffer.wrap(buff, start, end - start));
+        CharBuffer cb;
+        if (malformedInputAction == CodingErrorAction.REPLACE && unmappableCharacterAction == CodingErrorAction.REPLACE) {
+            cb = charset.decode(ByteBuffer.wrap(buff, start, end - start));
+        } else {
+            cb = charset.newDecoder().onMalformedInput(malformedInputAction)
+                    .onUnmappableCharacter(unmappableCharacterAction).decode(ByteBuffer.wrap(buff, start, end - start));
+        }
         return new String(cb.array(), cb.arrayOffset(), cb.length());
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org