diff options
author | Josh Rosen <joshrosen@databricks.com> | 2015-11-18 16:00:35 -0800 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2015-11-18 16:00:35 -0800 |
commit | 4b117121900e5f242e7c8f46a69164385f0da7cc (patch) | |
tree | 3134b152d511565a7bc4ba7b2cc8e61f859a9f2a /network/common | |
parent | c07a50b86254578625be777b1890ff95e832ac6e (diff) | |
download | spark-4b117121900e5f242e7c8f46a69164385f0da7cc.tar.gz spark-4b117121900e5f242e7c8f46a69164385f0da7cc.tar.bz2 spark-4b117121900e5f242e7c8f46a69164385f0da7cc.zip |
[SPARK-11495] Fix potential socket / file handle leaks that were found via static analysis
The HP Fortify Opens Source Review team (https://www.hpfod.com/open-source-review-project) reported a handful of potential resource leaks that were discovered using their static analysis tool. We should fix the issues identified by their scan.
Author: Josh Rosen <joshrosen@databricks.com>
Closes #9455 from JoshRosen/fix-potential-resource-leaks.
Diffstat (limited to 'network/common')
-rw-r--r-- | network/common/src/test/java/org/apache/spark/network/ChunkFetchIntegrationSuite.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/network/common/src/test/java/org/apache/spark/network/ChunkFetchIntegrationSuite.java b/network/common/src/test/java/org/apache/spark/network/ChunkFetchIntegrationSuite.java index dc5fa1cee6..50a324e293 100644 --- a/network/common/src/test/java/org/apache/spark/network/ChunkFetchIntegrationSuite.java +++ b/network/common/src/test/java/org/apache/spark/network/ChunkFetchIntegrationSuite.java @@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import com.google.common.io.Closeables; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -78,10 +79,15 @@ public class ChunkFetchIntegrationSuite { testFile = File.createTempFile("shuffle-test-file", "txt"); testFile.deleteOnExit(); RandomAccessFile fp = new RandomAccessFile(testFile, "rw"); - byte[] fileContent = new byte[1024]; - new Random().nextBytes(fileContent); - fp.write(fileContent); - fp.close(); + boolean shouldSuppressIOException = true; + try { + byte[] fileContent = new byte[1024]; + new Random().nextBytes(fileContent); + fp.write(fileContent); + shouldSuppressIOException = false; + } finally { + Closeables.close(fp, shouldSuppressIOException); + } final TransportConf conf = new TransportConf("shuffle", new SystemPropertyConfigProvider()); fileChunk = new FileSegmentManagedBuffer(conf, testFile, 10, testFile.length() - 25); @@ -117,6 +123,7 @@ public class ChunkFetchIntegrationSuite { @AfterClass public static void tearDown() { + bufferChunk.release(); server.close(); clientFactory.close(); testFile.delete(); |