This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new bf15939613 Avoid three possible NPEs
bf15939613 is described below
commit bf159396135f6e7bfef81efc9ed54482d294d9c7
Author: remm <[email protected]>
AuthorDate: Fri Sep 8 15:27:07 2023 +0200
Avoid three possible NPEs
Found by coverity.
---
java/org/apache/catalina/mbeans/ContextMBean.java | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/catalina/mbeans/ContextMBean.java
b/java/org/apache/catalina/mbeans/ContextMBean.java
index 39255ff5a1..4a50fcf5de 100644
--- a/java/org/apache/catalina/mbeans/ContextMBean.java
+++ b/java/org/apache/catalina/mbeans/ContextMBean.java
@@ -77,7 +77,12 @@ public class ContextMBean extends BaseCatalinaMBean<Context>
{
*/
public String findErrorPage(int errorCode) throws MBeanException {
Context context = doGetManagedResource();
- return context.findErrorPage(errorCode).toString();
+ ErrorPage errorPage = context.findErrorPage(errorCode);
+ if (errorPage != null) {
+ return context.findErrorPage(errorCode).toString();
+ } else {
+ return null;
+ }
}
@@ -108,7 +113,12 @@ public class ContextMBean extends
BaseCatalinaMBean<Context> {
*/
public String findErrorPage(Throwable exceptionType) throws MBeanException
{
Context context = doGetManagedResource();
- return context.findErrorPage(exceptionType).toString();
+ ErrorPage errorPage = context.findErrorPage(exceptionType);
+ if (errorPage != null) {
+ return errorPage.toString();
+ } else {
+ return null;
+ }
}
@@ -145,7 +155,11 @@ public class ContextMBean extends
BaseCatalinaMBean<Context> {
Context context = doGetManagedResource();
FilterDef filterDef = context.findFilterDef(name);
- return filterDef.toString();
+ if (filterDef != null) {
+ return filterDef.toString();
+ } else {
+ return null;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]