This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new afb4173fa2 Re-order checks to avoid NPE. Identified by Coverity Scan.
afb4173fa2 is described below
commit afb4173fa29c60ccf1def9b946deaba9bf71a44f
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Oct 14 07:43:12 2025 +0100
Re-order checks to avoid NPE. Identified by Coverity Scan.
---
java/org/apache/catalina/loader/WebappLoader.java | 6 +++---
webapps/docs/changelog.xml | 9 +++++++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/catalina/loader/WebappLoader.java
b/java/org/apache/catalina/loader/WebappLoader.java
index 5c8183e2e9..9b4f0994b7 100644
--- a/java/org/apache/catalina/loader/WebappLoader.java
+++ b/java/org/apache/catalina/loader/WebappLoader.java
@@ -466,6 +466,9 @@ public class WebappLoader extends LifecycleMBeanBase
implements Loader {
URL[] repositories = ((URLClassLoader) loader).getURLs();
for (URL url : repositories) {
String repository = url.toString();
+ if (repository == null) {
+ continue;
+ }
if (repository.startsWith("file:")) {
// Let the JRE handle all the edge cases for URL to path
conversion.
try {
@@ -477,9 +480,6 @@ public class WebappLoader extends LifecycleMBeanBase
implements Loader {
} else {
continue;
}
- if (repository == null) {
- continue;
- }
if (!classpath.isEmpty()) {
classpath.append(File.pathSeparator);
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 1c164baf16..986e8bb34b 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,15 @@
issues do not "pop up" wrt. others).
-->
<section name="Tomcat 11.0.14 (markt)" rtext="in development">
+ <subsection name="Catalina">
+ <changelog>
+ <fix>
+ When generating the class path in the Loader, re-order the check on
+ individual class path components to avoid a potential
+ <code>NullPointerException</code>. Identified by Coverity Scan. (markt)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="Other">
<changelog>
<update>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]