If a ServletRequestListener is defined, when is invoked after a call to AsyncContext#dispatch() the DispatcherType returned from the ServletRequest is REQUEST rather than ASYNC. When the actual servlet is invoked, the type is correctly set to ASYNC. If the listener is intended to be invoked for each dispatch, then the DispatcherType should match the value returned in the filter/servlet.
Created attachment 26663 [details] example using listener added to examples
Although invoking the listener on every dispatch strictly matches the Javadoc that says "A ServletRequest is defined as coming into scope of a web application when it is about to enter the first servlet or filter of the web application, and as going out of scope as it exits the last servlet or the first filter in the chain." However, that is the same definition as used before async support was added. The methods on the listener (requestInitialized/requestDestroyed) make it sound like the event should occur at the start and end of the request lifetime.
That was fun. It is always the simple looking bugs that are tricky to fix. I agree that these events should be fired once per request. There was already some code trying to ensure that this was the case but it was ineffective. I have fixed the problem and expanded the async test cases to cover this issue. The fix is in trunk and will be in 7.0.9 onwards.
Thanks