Skip to content

Commit 00d272f

Browse files
authored
Do not use javax.naming namespace in the catch block, so that Logback can be used without requiring the javax.naming module (#1004)
The InsertFromJNDIModelHandler is usually created when using Logback, but only used when JNDI is used in the logging configuration. Catching the javax.naming.NamingException will automatically resolve the class when the InsertFromJNDIModelHandler class is used, throwing an exception when it is not present. By catching the generic Exception, unless JNDI or SMTP are used, the javax.naming module is not required now. Signed-off-by: Marius Hanl <mariushanl@web.de>
1 parent 420d67c commit 00d272f

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

logback-core/src/main/java/ch/qos/logback/core/model/processor/InsertFromJNDIModelHandler.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package ch.qos.logback.core.model.processor;
22

3-
import javax.naming.NamingException;
4-
53
import ch.qos.logback.core.Context;
64
import ch.qos.logback.core.joran.action.ActionUtil;
75
import ch.qos.logback.core.joran.action.ActionUtil.Scope;
@@ -72,7 +70,7 @@ public void detachedHandle(ContextAwarePropertyContainer capc, InsertFromJNDIMod
7270
addInfo("Setting variable [" + asKey + "] to [" + envEntryValue + "] in [" + scope + "] scope");
7371
PropertyModelHandlerHelper.setProperty(capc, asKey, envEntryValue, scope);
7472
}
75-
} catch (NamingException e) {
73+
} catch (Exception e) {
7674
addError("Failed to lookup JNDI env-entry [" + envEntryName + "]");
7775
}
7876

0 commit comments

Comments
 (0)