This is an automated email from the ASF dual-hosted git repository.
markt 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 a5ab4db649 Re-order checks to avoid NPE. Identified by Coverity Scan.
a5ab4db649 is described below
commit a5ab4db649f24661d8ff865c34a46c2bccd09b89
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 | 5 +++++
2 files changed, 8 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 5ebd3398a7..b735b3dd53 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -181,6 +181,11 @@
<code>RemoteAddrValve</code>. (markt)
</update>
<!-- Entries for backport and removal before 12.0.0-M1 below this line
-->
+ <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="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]