File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 2121import ch .qos .logback .core .spi .ContextAwareImpl ;
2222import ch .qos .logback .core .status .InfoStatus ;
2323import ch .qos .logback .core .util .EnvUtil ;
24+ import ch .qos .logback .core .util .Loader ;
2425import ch .qos .logback .core .util .StatusListenerConfigHelper ;
2526
2627import java .util .Comparator ;
@@ -65,7 +66,12 @@ public void autoConfig() throws JoranException {
6566 autoConfig (Configurator .class .getClassLoader ());
6667 }
6768
69+
6870 public void autoConfig (ClassLoader classLoader ) throws JoranException {
71+
72+ // see https://github.com/qos-ch/logback/issues/715
73+ classLoader = Loader .systemClassloaderIfNull (classLoader );
74+
6975 String versionStr = EnvUtil .logbackVersion ();
7076 if (versionStr == null ) {
7177 versionStr = CoreConstants .NA ;
Original file line number Diff line number Diff line change @@ -56,6 +56,21 @@ public Boolean run() {
5656 });
5757 }
5858
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+
5974 /**
6075 * Compute the number of occurrences a resource can be found by a class loader.
6176 *
@@ -64,7 +79,6 @@ public Boolean run() {
6479 * @return
6580 * @throws IOException
6681 */
67-
6882 public static Set <URL > getResources (String resource , ClassLoader classLoader ) throws IOException {
6983 // See LBCLASSIC-159
7084 Set <URL > urlSet = new HashSet <URL >();
You can’t perform that action at this time.
0 commit comments