Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2018-01-02 04:41:16 -0500
committerMatthias Sohn2018-01-02 04:41:16 -0500
commit8b24d5046e5f2813d8df5f1b4a13ed8f323aea23 (patch)
treee25190478747a9944d1baf5a04f8d83731cb8641 /org.eclipse.egit.github.core
parent618dfdd09a2b0f686d4316d30ea3693d6a3f01ea (diff)
downloadegit-github-8b24d5046e5f2813d8df5f1b4a13ed8f323aea23.tar.gz
egit-github-8b24d5046e5f2813d8df5f1b4a13ed8f323aea23.tar.xz
egit-github-8b24d5046e5f2813d8df5f1b4a13ed8f323aea23.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: I2de6fc27d7fb593a946e9f6d9bb64873092e258c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.github.core')
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/DownloadService.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/DownloadService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/DownloadService.java
index 97c44421..6e859e47 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/DownloadService.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/DownloadService.java
@@ -16,13 +16,11 @@ import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOS
import static org.eclipse.egit.github.core.client.PagedRequest.PAGE_FIRST;
import static org.eclipse.egit.github.core.client.PagedRequest.PAGE_SIZE;
-import com.google.gson.reflect.TypeToken;
-
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
+import java.nio.file.Files;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -36,6 +34,8 @@ import org.eclipse.egit.github.core.client.PageIterator;
import org.eclipse.egit.github.core.client.PagedRequest;
import org.eclipse.egit.github.core.util.MultiPartUtils;
+import com.google.gson.reflect.TypeToken;
+
/**
* Service for accessing, creating, and deleting repositories downloads.
*
@@ -309,7 +309,7 @@ public class DownloadService extends GitHubService {
if (file == null)
throw new IllegalArgumentException("File cannot be null"); //$NON-NLS-1$
- return createDownload(repository, download, new FileInputStream(file),
+ return createDownload(repository, download, Files.newInputStream(file.toPath()),
file.length());
}
}

Back to the top