Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/15408#discussion_r83040126
--- Diff:
core/src/main/java/org/apache/spark/io/NioBufferedFileInputStream.java ---
@@ -72,30 +74,35 @@ private boolean refill() throws IOException {
}
@Override
- public int read() throws IOException {
+ public synchronized int read() throws IOException {
if (!refill()) {
return -1;
}
return byteBuffer.get() & 0xFF;
}
@Override
- public int read(byte[] b, int offset, int len) throws IOException {
+ public synchronized int read(byte[] b, int offset, int len) throws
IOException {
if (!refill()) {
return -1;
}
+ if ((offset | len | (offset + len) | (b.length - (offset + len))) < 0)
{
--- End diff --
I think this must be a typo... this is a bitwise-or of a bunch of ints. I
think maybe the example was given as a sort of pseudo code. offset and len
can't be negative and their sum shouldn't exceed the array lenght, but that
seems like it. 'else' below isn't really needed, but that's a nit. Actually,
you want to check whether len is after updating on line 94 right? if no data is
available you also return 0 without a no-op read?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]