-
Notifications
You must be signed in to change notification settings - Fork 5.8k
6766844: ByteArrayInputStream#read with a byte array of length 0 not consistent with InputStream when at EOF #4591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…consistent with InputStream when at EOF
👋 Welcome back bpb! A progress list of the required criteria for merging this PR into |
Webrevs
|
Looks good to me. Maybe add the bug id to the @bug tag of the test. |
@bplb This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 131 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Yeah I overlooked adding the bug ID to the test. |
/csr |
@AlanBateman has indicated that a compatibility and specification (CSR) request is needed for this pull request. |
I realize I submitted this issue a long time ago but I think we have to proceed with caution as it is changing long standing behavior. Reading with len==0 will arise with code that is reading in a loop and the "previous read" completely fills the array and reads all remaining bytes. It's possible that there is existing code that will break with this change. I've added the "csr" label for now. If this changes goes ahead then it will need a release note too. |
I had the same misgivings after creating this PR and thought that a CSR would be in order. |
CSR JDK-8269399 created. |
The spec for ByteArrayInputStream.read(byte[], off, len) is pretty specific about returning -1 if there is nothing to read. |
@RogerRiggs I agree. |
3152cdc
to
df884a4
Compare
df884a4
to
a53849a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that clarifying the spec would be a much safer solution.
CSR revised to match. |
This PR has been superseded by the JDK 17 PR 189. |
Modify
java.io.ByteArrayInputStream
methodsread(byte[])
andread(byte[],int,int)
to return zero per theInputStream
specification when the byte array actual or specified length is zero.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4591/head:pull/4591
$ git checkout pull/4591
Update a local copy of the PR:
$ git checkout pull/4591
$ git pull https://git.openjdk.java.net/jdk pull/4591/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4591
View PR using the GUI difftool:
$ git pr show -t 4591
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4591.diff