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
Fix #1623: Fix an infinite loop in j.i.RandomAccessFile#readLine #2100
Fix #1623: Fix an infinite loop in j.i.RandomAccessFile#readLine #2100
Conversation
@WojciechMazur Thank you for the timely review & approval. Always nice to have a second set of eyes, especially Not trying to push the river, but rather to understand the process. Do I need to do anything to get this merged or just |
var end = length() // standard practice: 1 past last valid byte. | ||
if (pos >= end) { | ||
null // JDK 8 specification requires null here. | ||
} else { | ||
val builder = new StringBuilder |
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.
This isn't specifically part of the PR but I think we should be using java.lang.StringBuilder
here to remove the Scala lib dependency.
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.
Good suggestion, good eyes! Thank you. Review leads to better code all around.
Since that line is new code, I think that making the change you suggest does not
break the "unity of purpose" required of a PR.
Easy enough to write to current practices and not introduce technical debt.
Other Scala lib dependencies may have crept in but I know of no easy way
to find them all at once. At least this one is gone. Others as they are found
(We will have to have a planned, but "Turn off Predef" bugfix week sometime).
We correct the condition which lead to a user reporting an infinite loop. Previously, two-byte Chars were being used where 1-byte Bytes should have been. This PR updates and supersedes now closed PR scala-native#1624. The latter has extensive notes which may aid future developers.
ddb07c0
to
b9205c4
Compare
…eadLine (scala-native#2100) We correct the condition which lead to an infinite loop. Previously, we read two-byte Chars instead of 1-byte Bytes.
…eadLine (scala-native#2100) We correct the condition which lead to an infinite loop. Previously, we read two-byte Chars instead of 1-byte Bytes.
We correct the condition which lead to an infinite loop.
Previously, two-byte Chars were being used where 1-byte Bytes
should have been.
This PR updates and supersedes now closed PR #1624. The latter
has extensive notes which may aid future developers.