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

    https://github.com/apache/spark/pull/14093#discussion_r70105908
  
    --- Diff: 
core/src/main/java/org/apache/spark/shuffle/sort/UnsafeShuffleWriter.java ---
    @@ -349,12 +349,19 @@ void forceSorterToSpill() throws IOException {
             for (int i = 0; i < spills.length; i++) {
               final long partitionLengthInSpill = 
spills[i].partitionLengths[partition];
               if (partitionLengthInSpill > 0) {
    -            InputStream partitionInputStream =
    -              new LimitedInputStream(spillInputStreams[i], 
partitionLengthInSpill);
    -            if (compressionCodec != null) {
    -              partitionInputStream = 
compressionCodec.compressedInputStream(partitionInputStream);
    +            InputStream partitionInputStream = null;
    +            boolean innerThrewException = true;
    --- End diff --
    
    This is the typical way to use `Closeables.close` in Java. The same pattern 
is used for the outer try/finally that is already there and is in [Guava's 
documentation|https://google.github.io/guava/releases/19.0/api/docs/com/google/common/io/Closeables.html#close(java.io.Closeable,
 boolean)].
    
    I'm reluctant to change from the standard pattern for aesthetic reasons 
when `finally` is the correct control flow -- the stream should always be 
closed regardless of exceptions.


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