Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
If one builds a request filter that use ApplicationStateManager, a call to any intersting method of the ASM throws an NPE.
The problem is that the ApplicationStateManager use the session as default storage strategy, and that he tries to take it trough the RequesGlobals#getRequest that returns null in the request handler.
It's an expected behavior since the RequestGlobals#storeRequestResponse method is called in the terminator of the RequestFilter pipeline. Perhpas there is a good reason to do it so, and not in the head of the pipeline, but I don't see it.
Notice: it's exactly the same thing for HttpRequest/HttpResponse and HttpServletRequestHandler and storeServletRequestResponse
Workaround : contribute a RequestFilter before any other whose sole action is to set Request/Response:
public static RequestFilter buildSetRequestResponse(final RequestGlobals requestGlobals) {
return new RequestFilter(){
public boolean service(Request request, Response response, RequestHandler handler) throws IOException
};
}
public static void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration,
@InjectService("setRequestResponse") RequestFilter setRequestResponse,
...other filters...) {
configuration.add("setRequestResponse", setRequestResponse, "before:*");
...other configurations...
}
Attachments
Issue Links
- relates to
-
TAP5-456 NPE in HttpServletRequestFilter if ApplicationStateManager is used
- Closed