You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2021/02/03 12:13:45 UTC
[myfaces-tobago] 01/03: fix: NullPointerException while AJAX
exception handling issue: TOBAGO-2068
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
commit 7e443258d13d19b9282fbc1acddee8bf950209a1
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Wed Feb 3 12:02:33 2021 +0100
fix: NullPointerException while AJAX exception handling
issue: TOBAGO-2068
---
.../apache/myfaces/tobago/util/WebXmlUtils.java | 70 ++++++++++++----------
1 file changed, 37 insertions(+), 33 deletions(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/WebXmlUtils.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/WebXmlUtils.java
index 3fe0498..c3cc075 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/WebXmlUtils.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/WebXmlUtils.java
@@ -58,10 +58,12 @@ public class WebXmlUtils {
String location = null;
- Class<?> exceptionClass = exception.getClass();
- while (exceptionClass != null && location == null) {
- location = ERROR_PAGE_LOCATIONS.get(exceptionClass);
- exceptionClass = exceptionClass.getSuperclass();
+ if (exception != null) {
+ Class<?> exceptionClass = exception.getClass();
+ while (exceptionClass != null && location == null) {
+ location = ERROR_PAGE_LOCATIONS.get(exceptionClass);
+ exceptionClass = exceptionClass.getSuperclass();
+ }
}
if (location == null) {
@@ -82,37 +84,39 @@ public class WebXmlUtils {
String location500 = null;
for (final Document document : webXmls) {
- final NodeList errorPages = document.getElementsByTagName("error-page");
-
- for (int i = 0; i < errorPages.getLength(); i++) {
- final Node errorPage = errorPages.item(i);
-
- String errorCode = null;
- String exceptionType = null;
- String location = null;
-
- final NodeList children = errorPage.getChildNodes();
- for (int j = 0; j < children.getLength(); j++) {
- final Node child = children.item(j);
- final String name = child.getNodeName();
-
- if ("error-code".equals(name)) {
- errorCode = child.getFirstChild().getNodeValue().trim();
- } else if ("exception-type".equals(name)) {
- exceptionType = child.getFirstChild().getNodeValue().trim();
- } else if ("location".equals(name)) {
- location = child.getFirstChild().getNodeValue().trim();
+ if (document != null) {
+ final NodeList errorPages = document.getElementsByTagName("error-page");
+
+ for (int i = 0; i < errorPages.getLength(); i++) {
+ final Node errorPage = errorPages.item(i);
+
+ String errorCode = null;
+ String exceptionType = null;
+ String location = null;
+
+ final NodeList children = errorPage.getChildNodes();
+ for (int j = 0; j < children.getLength(); j++) {
+ final Node child = children.item(j);
+ final String name = child.getNodeName();
+
+ if ("error-code".equals(name)) {
+ errorCode = child.getFirstChild().getNodeValue().trim();
+ } else if ("exception-type".equals(name)) {
+ exceptionType = child.getFirstChild().getNodeValue().trim();
+ } else if ("location".equals(name)) {
+ location = child.getFirstChild().getNodeValue().trim();
+ }
}
- }
- if (exceptionType != null) {
- final Class<Throwable> key = (Class<Throwable>) Class.forName(exceptionType);
- final String value = normalizePath(externalContext, location);
- ERROR_PAGE_LOCATIONS.put(key, value);
- } else if ("500".equals(errorCode)) {
- location500 = location;
- } else if (errorCode == null && exceptionType == null) {
- locationDefault = location;
+ if (exceptionType != null) {
+ final Class<Throwable> key = (Class<Throwable>) Class.forName(exceptionType);
+ final String value = normalizePath(externalContext, location);
+ ERROR_PAGE_LOCATIONS.put(key, value);
+ } else if ("500".equals(errorCode)) {
+ location500 = location;
+ } else if (errorCode == null && exceptionType == null) {
+ locationDefault = location;
+ }
}
}
}