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

    https://github.com/apache/spark/pull/12944#discussion_r73609047
  
    --- Diff: 
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockResolver.java
 ---
    @@ -261,24 +280,17 @@ private ManagedBuffer getSortBasedShuffleBlockData(
         File indexFile = getFile(executor.localDirs, 
executor.subDirsPerLocalDir,
           "shuffle_" + shuffleId + "_" + mapId + "_0.index");
     
    -    DataInputStream in = null;
         try {
    -      in = new DataInputStream(new FileInputStream(indexFile));
    -      in.skipBytes(reduceId * 8);
    -      long offset = in.readLong();
    -      long nextOffset = in.readLong();
    +      ShuffleIndexInformation shuffleIndexInformation = 
shuffleIndexCache.get(indexFile);
    +      ShuffleIndexRecord shuffleIndexRecord = 
shuffleIndexInformation.getIndex(reduceId);
    --- End diff --
    
    It turns out that this call will fail with `ArrayIndexOutOfBoundsException` 
if the `reduceId` is too large. In the old code, an invalid `reduceId` would 
lead to an `IOException` because we'd skip past the end of the input stream and 
try to read.
    
    However, I don't think that this subtle change in behavior is going to 
necessarily cause problems from the caller's perspective since 
`ArrayIndexOutOfBoundsException` is also a `RuntimeException` and this code was 
already throwing `RuntimeException` in the "index file is missing" error case. 
Therefore, this looks good to me!


---
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]

Reply via email to