Skip to content
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

FastByteArrayInputStream.read returns incorrect result [SPR-14209] #18783

Closed
spring-issuemaster opened this issue Apr 22, 2016 · 1 comment
Closed
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Apr 22, 2016

Javier Godoy opened SPR-14209 and commented

FastByteArrayInputStream.read(byte[]) returns incorrect result when the read buffer is bigger than the InputStream contents.

FastByteArrayOutputStream out = new FastByteArrayOutputStream();
out.write(new byte[42]);
System.out.println(out.getInputStream().read(new byte[43]));

Actual output: 41
Expected output: 42

The FBAIN implementation first reads all the available input, and a temporary read count of n is computed. Then it calls read again, which returns -1 (end of stream). That -1 is added to the read count, returning n-1 instead of n.


Affects: 4.2.5

Issue Links:

  • #18809 FastByteArrayInputStream read( byte[] ) wrong return value ("is duplicated by")

Referenced from: commits 9bf5a5c, b9fa67e

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 23, 2016

Juergen Hoeller commented

Good catch! Fixed for 4.2.6 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.