Skip to content

Commit 779bd50

Browse files
committed
Removed logging code from DirectoryClassLoader
The class loader is instantiated before dynamically loaded jars are added. This means, if the slf4j backend implementation is loaded using this mechanism (which should be the default), the backend is not yet available when the DirectoryClassLoader is created. This will cause slf4j to use the no operation logger which is not what the user expects.
1 parent 47a5b73 commit 779bd50

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/main/java/org/culturegraph/mf/runner/util/DirectoryClassLoader.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
import java.net.URL;
2222
import java.net.URLClassLoader;
2323

24-
import org.slf4j.Logger;
25-
import org.slf4j.LoggerFactory;
24+
import org.culturegraph.mf.exceptions.MetafactureException;
2625

2726
/**
2827
* A class loader which allows adding directories to the class
@@ -33,8 +32,6 @@
3332
*/
3433
public final class DirectoryClassLoader extends URLClassLoader {
3534

36-
private static final Logger LOG = LoggerFactory.getLogger(DirectoryClassLoader.class);
37-
3835
private static final String JAR_FILE_EXTENSION = ".jar";
3936
private static final String CLASS_FILE_EXTENSION = ".class";
4037

@@ -53,13 +50,11 @@ public DirectoryClassLoader(final ClassLoader parent) {
5350
}
5451

5552
public void addDirectory(final File dir) {
56-
LOG.info("Adding jar and class files in {} to class loader", dir);
5753
for (final File file : dir.listFiles(JAR_AND_CLASS_FILTER)) {
5854
try {
59-
LOG.info("Adding {} to class loader", file);
6055
addURL(file.toURI().toURL());
6156
} catch (final MalformedURLException e) {
62-
LOG.error("Could not add {} to class loader: {}", file, e);
57+
throw new MetafactureException("Could not add " + file + " to class loader", e);
6358
}
6459
}
6560
}

0 commit comments

Comments
 (0)