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: I3cef6fcf198dde2be7cd15bded8d2fa247177654
This commit is contained in:
@@ -20,10 +20,10 @@ import static com.google.gerrit.pgm.init.InitPlugins.PLUGIN_DIR;
|
||||
import com.google.gerrit.pgm.init.PluginsDistribution;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.ServletContext;
|
||||
@@ -45,7 +45,7 @@ class UnzippedDistribution implements PluginsDistribution {
|
||||
for (File p : list) {
|
||||
String pluginJarName = p.getName();
|
||||
String pluginName = pluginJarName.substring(0, pluginJarName.length() - JAR.length());
|
||||
try (InputStream in = new FileInputStream(p)) {
|
||||
try (InputStream in = Files.newInputStream(p.toPath())) {
|
||||
processor.process(pluginName, in);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user