diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2017-07-28 23:07:27 +0300 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2017-07-28 23:07:27 +0300 |
commit | c7a95d5ea039b26497ecd4d8acc800f8a3b4d7bb (patch) | |
tree | 0dc18c25891890ecf7d1a250f7f66fd90b82fede | |
parent | c9bdd98e6df7c146377f8b7d56146bfae7d5a797 (diff) | |
download | pf4j-c7a95d5ea039b26497ecd4d8acc800f8a3b4d7bb.tar.gz pf4j-c7a95d5ea039b26497ecd4d8acc800f8a3b4d7bb.zip |
Possible fix for #156
3 files changed, 17 insertions, 12 deletions
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java index 952f6d4..4f5f3bb 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java @@ -21,8 +21,8 @@ import java.util.List; import java.util.Set; /** - * The default implementation for ExtensionFinder. - * It's a compound ExtensionFinder. + * The default implementation for {@link ExtensionFinder}. + * It's a compound {@code ExtensionFinder}. * * @author Decebal Suiu */ diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java index ff5379c..6814fa3 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/LegacyExtensionFinder.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Enumeration; import java.util.HashSet; import java.util.LinkedHashMap; @@ -31,8 +32,8 @@ import java.util.Map; import java.util.Set; /** - * All extensions declared in a plugin are indexed in a file "META-INF/extensions.idx". - * This class lookup extensions in all extensions index files "META-INF/extensions.idx". + * All extensions declared in a plugin are indexed in a file {@code META-INF/extensions.idx}. + * This class lookup extensions in all extensions index files {@code META-INF/extensions.idx}. * * @author Decebal Suiu */ @@ -55,8 +56,9 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder { while (urls.hasMoreElements()) { URL url = urls.nextElement(); log.debug("Read '{}'", url.getFile()); - Reader reader = new InputStreamReader(url.openStream(), "UTF-8"); - LegacyExtensionStorage.read(reader, bucket); + try (Reader reader = new InputStreamReader(url.openStream(), StandardCharsets.UTF_8)) { + LegacyExtensionStorage.read(reader, bucket); + } } debugExtensions(bucket); @@ -84,8 +86,9 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder { URL url = ((PluginClassLoader) plugin.getPluginClassLoader()).findResource(getExtensionsResource()); if (url != null) { log.debug("Read '{}'", url.getFile()); - Reader reader = new InputStreamReader(url.openStream(), "UTF-8"); - LegacyExtensionStorage.read(reader, bucket); + try (Reader reader = new InputStreamReader(url.openStream(), StandardCharsets.UTF_8)) { + LegacyExtensionStorage.read(reader, bucket); + } } else { log.debug("Cannot find '{}'", getExtensionsResource()); } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java index fae6b08..4912507 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/ServiceProviderExtensionFinder.java @@ -41,8 +41,8 @@ import java.util.Map; import java.util.Set; /** - * The ServiceLoader base implementation for ExtensionFinder. - * This class lookup extensions in all extensions index files "META-INF/services". + * The {@link java.util.ServiceLoader} base implementation for {@link ExtensionFinder}. + * This class lookup extensions in all extensions index files {@code META-INF/services}. * * @author Decebal Suiu */ @@ -133,8 +133,10 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { log.debug("Read '{}'", file); - Reader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8); - ServiceProviderExtensionStorage.read(reader, result); + try (Reader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) { + ServiceProviderExtensionStorage.read(reader, result); + } + return FileVisitResult.CONTINUE; } |