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;
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
*/
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);
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());
}
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
*/
@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;
}