Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2018-01-02 09:33:31 +0000
committerMatthias Sohn2019-01-04 01:25:57 +0000
commit336f868f0fb4e8599d55f5d47a621be97ed903c9 (patch)
treefd18f4255a09937aa5999dffedb439be898e0df6 /org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test
parent0649f38bf999d4a8e33f0ddf6ff2f7924afd62cd (diff)
downloadegit-336f868f0fb4e8599d55f5d47a621be97ed903c9.tar.gz
egit-336f868f0fb4e8599d55f5d47a621be97ed903c9.tar.xz
egit-336f868f0fb4e8599d55f5d47a621be97ed903c9.zip
Replace FileInputStream and FileOutputStream with static Files methods
FileInputStream and FileOutputStream rely on finalize() method to ensure resources are closed. This implies they are added to the finalizer queue which causes additional work for the JVM GC process. This is an open bug on the OpenJDK [1] and the recommended workaround is to use the Files.newInputStream and Files.newOutputStream static methods instead. [1] https://bugs.openjdk.java.net/browse/JDK-8080225 Change-Id: I59e72d0a12d70396a5cf558029c13e2a1b0d5741 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
index d701d66242..9a984b58d2 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
@@ -23,9 +23,9 @@ import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Files;
import java.util.ArrayList;
import org.eclipse.core.resources.IFile;
@@ -138,17 +138,16 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase {
test.create(new ByteArrayInputStream(new byte[0]), false, null);
File testFile = new File(test.getLocation().toString());
assertTrue(testFile.exists());
- FileInputStream fis = new FileInputStream(testFile);
- try {
+ try (InputStream fis = Files.newInputStream(testFile.toPath())) {
FileUtils.delete(testFile);
return;
} catch (IOException e) {
// the test makes sense only if deletion of
// a file with open stream fails
} finally {
- fis.close();
- if (testFile.exists())
+ if (testFile.exists()) {
FileUtils.delete(testFile);
+ }
}
final Image folderImage = PlatformUI.getWorkbench().getSharedImages()
.getImage(ISharedImages.IMG_OBJ_FOLDER);

Back to the top