Author: remy.maucherat(a)jboss.com
Date: 2012-06-07 09:48:42 -0400 (Thu, 07 Jun 2012)
New Revision: 2040
Modified:
trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
trunk/webapps/docs/changelog.xml
Log:
AS7-4232: Modify async error processing based on a stricter spec interpretation (not
really tested yet)
Modified: trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
===================================================================
--- trunk/java/org/apache/catalina/connector/CoyoteAdapter.java 2012-06-05 21:37:52 UTC
(rev 2039)
+++ trunk/java/org/apache/catalina/connector/CoyoteAdapter.java 2012-06-07 13:48:42 UTC
(rev 2040)
@@ -264,7 +264,9 @@
// Calling the container
connector.getContainer().getPipeline().getFirst().event(request,
response, request.getEvent());
- if (!error &&
(request.getAttribute(RequestDispatcher.ERROR_EXCEPTION) != null)) {
+ Request.AsyncContextImpl asyncContext = (Request.AsyncContextImpl)
request.getAsyncContext();
+ if (!error &&
((request.getAttribute(RequestDispatcher.ERROR_EXCEPTION) != null)
+ || (asyncContext != null && asyncContext.getError() !=
null))) {
// An unexpected exception occurred while processing the event, so
// error should be called
request.getEvent().setType(HttpEvent.EventType.ERROR);
@@ -344,6 +346,9 @@
req.getParameters().setQueryStringEncoding
(connector.getURIEncoding());
+ // Set the context classloader, since in that case it might not be set
+
Thread.currentThread().setContextClassLoader(CoyoteAdapter.class.getClassLoader());
+
}
// Check if the connector was stopped
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2012-06-05 21:37:52 UTC (rev
2039)
+++ trunk/java/org/apache/catalina/connector/Request.java 2012-06-07 13:48:42 UTC (rev
2040)
@@ -3368,6 +3368,7 @@
protected ServletContext servletContext = null;
protected String path = null;
protected Runnable runnable = null;
+ protected Throwable error = null;
protected boolean useAttributes = false;
protected boolean original = true;
protected boolean ready = true;
@@ -3469,6 +3470,7 @@
runnable = null;
useAttributes = false;
ready = true;
+ error = null;
}
public Map<AsyncListener, AsyncListenerRegistration> getAsyncListeners() {
@@ -3509,6 +3511,15 @@
return listenerInstance;
}
+ public Throwable getError() {
+ return error;
+ }
+
+ public void setError(Throwable error) {
+ ready = true;
+ this.error = error;
+ }
+
}
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2012-06-05 21:37:52 UTC
(rev 2039)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2012-06-07 13:48:42 UTC
(rev 2040)
@@ -583,9 +583,8 @@
asyncListenerRegistration.getRequest(),
asyncListenerRegistration.getResponse());
asyncListener.onTimeout(asyncEvent);
} else if (error) {
- Throwable t = (Throwable)
request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
AsyncEvent asyncEvent = new AsyncEvent(asyncContext,
- asyncListenerRegistration.getRequest(),
asyncListenerRegistration.getResponse(), t);
+ asyncListenerRegistration.getRequest(),
asyncListenerRegistration.getResponse(), asyncContext.getError());
asyncListener.onError(asyncEvent);
} else {
AsyncEvent asyncEvent = new AsyncEvent(asyncContext,
@@ -601,6 +600,9 @@
if (timeout && request.isEventMode() &&
asyncContext.getPath() == null) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
+ if (error && request.isEventMode() &&
asyncContext.getPath() == null) {
+ exception(request, response, asyncContext.getError());
+ }
} else if (asyncContext.getRunnable() != null) {
// Execute the runnable
try {
@@ -608,7 +610,7 @@
} catch (Throwable e) {
container.getLogger().error(sm.getString("standardWrapper.async.runnableError",
getContainer().getName()), e);
- exception(request, response, e);
+ asyncContext.setError(e);
}
} else if (asyncContext.getPath() != null) {
// We executed the dispatch
@@ -631,7 +633,7 @@
} catch (Throwable e) {
container.getLogger().error(sm.getString("standardWrapper.async.dispatchError",
getContainer().getName()), e);
- exception(request, response, e);
+ asyncContext.setError(e);
}
request.setCanStartAsync(false);
// If there is no new startAsync, then close the response
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2012-06-05 21:37:52 UTC (rev 2039)
+++ trunk/webapps/docs/changelog.xml 2012-06-07 13:48:42 UTC (rev 2040)
@@ -28,6 +28,14 @@
<fix>
Use the thread listener bind/unbind in the background process. (remm)
</fix>
+ <fix>
+ <jboss-jira>JBPAPP-9126</jboss-jira>: Set the context classloader as
soon as possible on newly
+ created threads. (remm)
+ </fix>
+ <fix>
+ <jboss-jira>AS7-4232</jboss-jira>: Modify async error processing
based on a stricter spec
+ interpretation. (remm)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
Show replies by date