This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp.git
The following commit(s) were added to refs/heads/master by this push:
new 5c883f7 SLING-11298 : NullPointerException when processing exceptions
5c883f7 is described below
commit 5c883f7718ef9f60afa0117f658296c703f1b538
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Thu May 5 18:09:12 2022 +0200
SLING-11298 : NullPointerException when processing exceptions
---
.../scripting/jsp/jasper/JspCompilationContext.java | 19 ++++++++++++-------
.../jsp/jasper/servlet/JspServletWrapper.java | 8 ++++----
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git
a/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
b/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
index 6ce4601..616c545 100644
---
a/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
+++
b/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
@@ -204,7 +204,7 @@ public class JspCompilationContext {
}
public Compiler getCompiler() {
- return jspCompiler;
+ return createCompiler();
}
/** ---------- Access resources in the webapp ---------- */
@@ -524,15 +524,20 @@ public class JspCompilationContext {
// ==================== Manipulating the class ====================
+ public String getClassName() {
+ String name;
+ if (isTagFile()) {
+ name = tagInfo.getTagClassName();
+ } else {
+ name = getServletPackageName() + "." + getServletClassName();
+ }
+ return name;
+ }
+
public Class<?> load()
throws JasperException {
try {
- String name;
- if (isTagFile()) {
- name = tagInfo.getTagClassName();
- } else {
- name = getServletPackageName() + "." + getServletClassName();
- }
+ final String name = this.getClassName();
final Class<?> servletClass = getClassLoader().loadClass(name);
return servletClass;
} catch (ClassNotFoundException cex) {
diff --git
a/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
b/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
index 67f2268..2dc7480 100644
---
a/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
+++
b/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
@@ -515,14 +515,14 @@ public class JspServletWrapper {
(HttpServletResponse.SC_SERVICE_UNAVAILABLE,
ex.getMessage());
return;
+ } catch (final SlingException ex) {
+ throw ex;
} catch (final ServletException ex) {
handleJspException(ex);
} catch (final IOException ex) {
handleJspException(ex);
} catch (final IllegalStateException ex) {
handleJspException(ex);
- } catch (final SlingPageException ex) {
- throw ex;
}catch (final Exception ex) {
handleJspException(ex);
}
@@ -635,7 +635,7 @@ public class JspServletWrapper {
StackTraceElement jspFrame = null;
for (int i=0; i<frames.length; ++i) {
- if (
frames[i].getClassName().equals(this.theServlet.getClass().getName()) ) {
+ if ( frames[i].getClassName().equals(this.ctxt.getClassName())
) {
jspFrame = frames[i];
break;
}
@@ -647,7 +647,7 @@ public class JspServletWrapper {
if ( ex instanceof ServletException ) {
return ex;
}
- return new SlingException(ex) {};
+ return new SlingException(ex.getMessage(), ex);
}
int javaLineNumber = jspFrame.getLineNumber();
JavacErrorDetail detail = ErrorDispatcher.createJavacError(