File tree 2 files changed +21
-1
lines changed
logback-classic/src/main/java/ch/qos/logback/classic/util
logback-core/src/main/java/ch/qos/logback/core/util
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 21
21
import ch .qos .logback .core .spi .ContextAwareImpl ;
22
22
import ch .qos .logback .core .status .InfoStatus ;
23
23
import ch .qos .logback .core .util .EnvUtil ;
24
+ import ch .qos .logback .core .util .Loader ;
24
25
import ch .qos .logback .core .util .StatusListenerConfigHelper ;
25
26
26
27
import java .util .Comparator ;
@@ -65,7 +66,12 @@ public void autoConfig() throws JoranException {
65
66
autoConfig (Configurator .class .getClassLoader ());
66
67
}
67
68
69
+
68
70
public void autoConfig (ClassLoader classLoader ) throws JoranException {
71
+
72
+ // see https://github.com/qos-ch/logback/issues/715
73
+ classLoader = Loader .systemClassloaderIfNull (classLoader );
74
+
69
75
String versionStr = EnvUtil .logbackVersion ();
70
76
if (versionStr == null ) {
71
77
versionStr = CoreConstants .NA ;
Original file line number Diff line number Diff line change @@ -56,6 +56,21 @@ public Boolean run() {
56
56
});
57
57
}
58
58
59
+ /**
60
+ * This method is used to sanitize the <code>cl</code> argument in case it is null.
61
+ *
62
+ * @param cl a class loader, may be null
63
+ * @return the system class loader if the <code>cl</code> argument is null, return <code>cl</code> otherwise.
64
+ *
65
+ * @since 1.4.12
66
+ */
67
+ public static ClassLoader systemClassloaderIfNull (ClassLoader cl ) {
68
+ if (cl == null )
69
+ return ClassLoader .getSystemClassLoader ();
70
+ else
71
+ return cl ;
72
+ }
73
+
59
74
/**
60
75
* Compute the number of occurrences a resource can be found by a class loader.
61
76
*
@@ -64,7 +79,6 @@ public Boolean run() {
64
79
* @return
65
80
* @throws IOException
66
81
*/
67
-
68
82
public static Set <URL > getResources (String resource , ClassLoader classLoader ) throws IOException {
69
83
// See LBCLASSIC-159
70
84
Set <URL > urlSet = new HashSet <URL >();
You can’t perform that action at this time.
0 commit comments