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 2021/09/01 11:22:14 UTC

[tomcat] branch 8.5.x updated: Update Commons Codec to 1.16-SNAPSHOT (2021-01-09)

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


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 075b389  Update Commons Codec to 1.16-SNAPSHOT (2021-01-09)
075b389 is described below

commit 075b3893a665fbeab8459e436b26abbe3fff6d69
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Sep 1 12:19:52 2021 +0100

    Update Commons Codec to 1.16-SNAPSHOT (2021-01-09)
    
    Minor refactoring of hasData()
---
 MERGE.txt                                                |  2 +-
 java/org/apache/tomcat/util/codec/binary/BaseNCodec.java | 14 +++++++++-----
 webapps/docs/changelog.xml                               |  4 ++++
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/MERGE.txt b/MERGE.txt
index 1948af3..7b10d6a 100644
--- a/MERGE.txt
+++ b/MERGE.txt
@@ -43,7 +43,7 @@ Codec
 Sub-tree:
 src/main/java/org/apache/commons/codec
 The SHA1 ID / tag for the most recent commit to be merged to Tomcat is:
-2e9785b93a2aacedd84abc6a646cdb200940b818 (2021-01-15)
+fd44e6b491c9d606d0b91ac0029269d265024cd9 (2021-09-01)
 Note: Only classes required for Base64 encoding/decoding. The rest are removed.
 
 FileUpload
diff --git a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
index 0d29096..177e3ea 100644
--- a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
+++ b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
@@ -323,7 +323,7 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder {
      * @return The amount of buffered data available for reading.
      */
     int available(final Context context) {  // package protected for access from I/O streams
-        return context.buffer != null ? context.pos - context.readPos : 0;
+        return hasData(context) ? context.pos - context.readPos : 0;
     }
 
     /**
@@ -553,7 +553,7 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder {
      * @return true if there is data still available for reading.
      */
     boolean hasData(final Context context) {  // package protected for access from I/O streams
-        return context.buffer != null;
+        return context.pos > context.readPos;
     }
 
     /**
@@ -616,12 +616,16 @@ public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder {
      * @return The number of bytes successfully extracted into the provided byte[] array.
      */
     int readResults(final byte[] b, final int bPos, final int bAvail, final Context context) {
-        if (context.buffer != null) {
+        if (hasData(context)) {
             final int len = Math.min(available(context), bAvail);
             System.arraycopy(context.buffer, context.readPos, b, bPos, len);
             context.readPos += len;
-            if (context.readPos >= context.pos) {
-                context.buffer = null; // so hasData() will return false, and this method can return -1
+            if (!hasData(context)) {
+                // All data read.
+                // Reset position markers but do not set buffer to null to allow its reuse.
+                // hasData(context) will still return false, and this method will return 0 until
+                // more data is available, or -1 if EOF.
+                context.pos = context.readPos = 0;
             }
             return len;
         }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e5000c0..41196b3 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -188,6 +188,10 @@
         Update the internal fork of Apache Commons BCEL to 40d5eb4 (2021-09-01,
         6.6.0-SNAPSHOT). Code clean-up only. (markt)
       </add>
+      <add>
+        Update the internal fork of Apache Commons Codec to fd44e6b (2021-09-01,
+        1.16-SNAPSHOT). Minor refactoring. (markt)
+      </add>
     </changelog>
   </subsection>
 </section>

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