Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15408#discussion_r83171663
  
    --- 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 --
    
    @zsxwing oh I get it, you're really just checking if any top bit is set. 
Hm, that seems fairly obscure compared to just checking the arguments. Sure 
it's a little more code, but it's readable and i don't think this is 
performance critical? I hadn't seen this before and had to think a while to get 
what it does.
    
    Yes, I'm agreeing that offset and len can't be _allowed_ to be negative, 
not that it can't be specified by the caller as something negative.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to