You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2023/09/15 13:31:58 UTC
[tomcat] branch main updated: Avoid unlikely NPE
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 9aeef80e3b Avoid unlikely NPE
9aeef80e3b is described below
commit 9aeef80e3b450a1932426e387617fb065b8f7869
Author: remm <re...@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org