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:21:38 UTC
[tomcat] branch 10.0.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 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.0.x by this push:
new 524c544 Update Commons Codec to 1.16-SNAPSHOT (2021-01-09)
524c544 is described below
commit 524c5440531ac502cae33140658c35c01ecb966c
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 d4331ba..6ca10ac 100644
--- a/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
+++ b/java/org/apache/tomcat/util/codec/binary/BaseNCodec.java
@@ -318,7 +318,7 @@ public abstract class BaseNCodec {
* @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;
}
/**
@@ -502,7 +502,7 @@ public abstract class BaseNCodec {
* @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;
}
/**
@@ -565,12 +565,16 @@ public abstract class BaseNCodec {
* @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 2c186d3..6520550 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -207,6 +207,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