aboutsummaryrefslogtreecommitdiffstats
path: root/pf4j/src/main
diff options
context:
space:
mode:
authorhazemkmammu <hazemkmammu@users.noreply.github.com>2019-06-05 03:03:11 +0530
committerDecebal Suiu <decebal.suiu@gmail.com>2019-06-05 00:33:11 +0300
commit553a0753f59870b29515b05013ad4f1a0ef547d7 (patch)
tree171101a125452a7d9b8f2d30b1ae803d6d15e234 /pf4j/src/main
parenta0a645ffdd924d17f431a5db49ce4b24e9c88e58 (diff)
downloadpf4j-553a0753f59870b29515b05013ad4f1a0ef547d7.tar.gz
pf4j-553a0753f59870b29515b05013ad4f1a0ef547d7.zip
Fix FileSystemException in windows on plugin delete (#322)
Diffstat (limited to 'pf4j/src/main')
-rw-r--r--pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java b/pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java
index 99e1313..33adc27 100644
--- a/pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java
+++ b/pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java
@@ -20,6 +20,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
@@ -81,11 +82,14 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder {
Set<String> bucket = new HashSet<>();
try {
- Enumeration<URL> urls = ((PluginClassLoader) plugin.getPluginClassLoader()).findResources(getExtensionsResource());
- if (urls.hasMoreElements()) {
- collectExtensions(urls, bucket);
- } else {
- log.debug("Cannot find '{}'", getExtensionsResource());
+ log.debug("Read '{}'", getExtensionsResource());
+ ClassLoader pluginClassLoader = plugin.getPluginClassLoader();
+ try (InputStream resourceStream = pluginClassLoader.getResourceAsStream(getExtensionsResource())) {
+ if (resourceStream == null) {
+ log.debug("Cannot find '{}'", getExtensionsResource());
+ } else {
+ collectExtensions(resourceStream, bucket);
+ }
}
debugExtensions(bucket);
@@ -103,9 +107,13 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder {
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
log.debug("Read '{}'", url.getFile());
- try (Reader reader = new InputStreamReader(url.openStream(), StandardCharsets.UTF_8)) {
- LegacyExtensionStorage.read(reader, bucket);
- }
+ collectExtensions(url.openStream(), bucket);
+ }
+ }
+
+ private void collectExtensions(InputStream inputStream, Set<String> bucket) throws IOException {
+ try (Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
+ LegacyExtensionStorage.read(reader, bucket);
}
}