FastByteArrayOutputStream input stream rejects valid skip(long) arguments
メンテナーはふだん 1 日以内に返信
@hickey-ai がすでに取り組んでいます。
2026年10月17日 から。
評価
調査の方向性
バグは spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java の入力ストリームの skip(long) メソッドにあります。このメソッドは、残りのバイト数を確認する前に、負の値や大きすぎる値を拒否しています。issue の Repro.java をコンパイルして実行し、2 つの IllegalArgumentException のケースを確認してください。skip(-1) が 0 を返し、skip(Integer.MAX_VALUE + 1) が残りのバイト数を返せば完了です。既存のテストがすべて引き続き通ることも条件です。
索引モデルが issue の本文から書いたものです。
説明
Affected versions
Verified with the published spring-core 7.0.9 and 6.2.19 artifacts on JDK 21. The same result was reproduced with the affected classes compiled from main at 85a532dce455655aec8fd5a301b37c6c5ceda5bb, with the remaining dependencies supplied by spring-core 7.0.9. This was a focused reproduction, not a full Gradle build.
Problem
The input stream returned by FastByteArrayOutputStream.getInputStream() throws IllegalArgumentException from skip(long) for negative amounts and for amounts larger than Integer.MAX_VALUE.
The InputStream contract says negative amounts skip no bytes and return 0. A large positive amount should skip the available bytes, even if fewer than requested are available. This can break generic stream code that uses a long skip amount independent of the backing stream's capacity.
The reproduction below buffers only three bytes; it does not require a large allocation.
Minimal reproduction
Save as Repro.java:
import java.io.ByteArrayInputStream;
import org.springframework.util.FastByteArrayOutputStream;
public class Repro {
public static void main(String[] args) throws Exception {
byte[] bytes = {1, 2, 3};
var output = new FastByteArrayOutputStream();
output.write(bytes);
for (long amount : new long[] {-1, (long) Integer.MAX_VALUE + 1}) {
System.out.println("JDK: " + new ByteArrayInputStream(bytes).skip(amount));
try {
System.out.println("Spring: " + output.getInputStream().skip(amount));
} catch (IllegalArgumentException ex) {
System.out.println("Spring: " + ex);
}
}
}
}
Run on Java 17 or later:
curl -fLO https://repo.maven.apache.org/maven2/org/springframework/spring-core/7.0.9/spring-core-7.0.9.jar
java -cp spring-core-7.0.9.jar Repro.java
Actual output:
JDK: 0
Spring: java.lang.IllegalArgumentException: n must be 0 or greater: -1
JDK: 3
Spring: java.lang.IllegalArgumentException: n exceeds maximum (2147483647): 2147483648
Expected: the Spring results should also be 0 and 3, respectively. A positive request larger than the stream's remaining size should simply consume the remaining bytes.
Cause
FastByteArrayInputStream.skip rejects those values before examining the available bytes. The stream's int-sized internal buffers do not require rejection of long requests; the request can be bounded by the remaining byte count before conversion.
See the Java InputStream.skip contract.
Related reports checked
I searched issues and pull requests for FastByteArrayOutputStream skip, FastByteArrayInputStream, and skip Integer.MAX_VALUE. The older reports found (#18431, #18783, #18809, #22024) concern read/EOF behavior, not the skip argument handling above. I did not find a direct duplicate.
- 主要言語
- Java
- スター
- 60.3k
- フォーク
- 38.7k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 36
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
spring-projects/spring-framework のほかの issue
-
`YamlProcessor.getFlattenedMap` with `includeEmpty` returns a `null` key for an empty root mapping再び着手できるかも @erfannvb が 7 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
spring-projects/spring-framework#37522 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`WebClient` with default codecs drops `ProblemDetail` extension members再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
spring-projects/spring-framework#37503 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
StandardApiVersionDeprecationHandler generates nonconforming Sunset HTTP dates再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
spring-projects/spring-framework#37486 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
LinkedCaseInsensitiveMap.keySet().remove returns false after removing a null-valued entry再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンstatus: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
spring-projects/spring-framework#37470 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
ServerSentEventHttpMessageReader does not recognize data fields without a colon再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンin: web status: waiting-for-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
spring-projects/spring-framework#37461 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
spring-projects/spring-framework の issue をすべて見る
似ている issue
-
agent:working bug follow-up lane:auto
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Sanne/incus-spawn#1765 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
checkstyle/checkstyle#22260 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
strimzi/strimzi-kafka-operator#13328 · コメント 1 件 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信