access-log does not output the original query string after the servlet request is forwarded with new query strings in EAP 7

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7.x

Issue

When a servlet request is forward to a different path with a new query string, the request line attribute (%r) does not output a query string of the original request in the access log.

For example, when the following dispatcher.forward() is implemented in the application like the following:

RequestDispatcher dispatcher = request.getRequestDispatcher("/test?foo=bar");
dispatcher.forward(request, response);

then the following request is sent to the above code:

$ curl -v http://localhost:8080/example/?aaa=bbb

The access-log should output the request line with the original query string (?aaa=bbb), but it output with the new query string (?foo=bar) of the forwarded request:

127.0.0.1 - - [10/Oct/2019:20:20:54 +0900] "GET /example/?foo=bar HTTP/1.1" 200 68

Resolution

This is a bug in the JBoss EAP 7 (Undertow). The following JIRA was raised not to throw NullPointerException. This has been fixed in EAP 7.2.6 or later.

To work around this issue, you can implement and use the custom ExchangeAttribute and HandlerBuilder like This content is not included.undertow-custom-accesslog-exchangeattribute.zip which is attached in the JIRA This content is not included.JBEAP-17768. See README.md in the undertow-custom-accesslog-exchangeattribute.zip for details of the usage.

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.