This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 16512fd0a2 Avoid unlikely NPE 16512fd0a2 is described below commit 16512fd0a250aa202b00da11d2e7cae97d6669bf Author: remm <r...@apache.org> AuthorDate: Fri Sep 15 15:31:25 2023 +0200 Avoid unlikely NPE Found by coverity. --- java/org/apache/naming/NamingContext.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/java/org/apache/naming/NamingContext.java b/java/org/apache/naming/NamingContext.java index cefa30f37b..5503aa3658 100644 --- a/java/org/apache/naming/NamingContext.java +++ b/java/org/apache/naming/NamingContext.java @@ -867,14 +867,17 @@ public class NamingContext implements Context { // Use the configured object factory to resolve it directly if possible // Note: This may need manual constructor reflection configuration Reference reference = (Reference) entry.value; - Class<?> factoryClass = getClass().getClassLoader().loadClass(reference.getFactoryClassName()); - ObjectFactory factory = (ObjectFactory) factoryClass.getDeclaredConstructor().newInstance(); - obj = factory.getObjectInstance(entry.value, name, this, env); + String factoryClassName = reference.getFactoryClassName(); + if (factoryClassName != null) { + Class<?> factoryClass = getClass().getClassLoader().loadClass(factoryClassName); + ObjectFactory factory = (ObjectFactory) factoryClass.getDeclaredConstructor().newInstance(); + obj = factory.getObjectInstance(entry.value, name, this, env); + } } if (entry.value instanceof ResourceRef) { boolean singleton = Boolean.parseBoolean( (String) ((ResourceRef) entry.value).get( - "singleton").getContent()); + ResourceRef.SINGLETON).getContent()); if (singleton) { entry.type = NamingEntry.ENTRY; entry.value = obj; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org