-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jetty 12.0.x 12191 alt debug listener #12254
Jetty 12.0.x 12191 alt debug listener #12254
Conversation
…x.adoc Co-authored-by: Greg Wilkins <gregw@webtide.com>
…x.adoc Co-authored-by: Greg Wilkins <gregw@webtide.com>
…x.adoc Co-authored-by: Greg Wilkins <gregw@webtide.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree removing module for per debug listener is a good idea, but lets keep the mechanism and document it.
This handler setup is OK, but the handler itself is in need of updating.
[[eeN-debug]] | ||
== Module `{ee-all}-debug` | ||
include::{jetty-home}/modules/ee10-debug.mod[tags=description] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is N, all and 10 in this paragraph
@@ -76,17 +95,44 @@ public boolean handle(Request request, Response response, Callback callback) thr | |||
finally | |||
{ | |||
// TODO this should be done in a completion event | |||
print(name, "RESPONSE " + response.getStatus() + (ex == null ? "" : ("/" + ex)) + " " + response.getHeaders().get(HttpHeader.CONTENT_TYPE)); | |||
log("<< r=%s async=false %d%n%s", rname, response.getStatus(), response.getHeaders()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to fix the TODO. At the time this finally block is called, the response status and headers may not be set, or we may be in a race with them being set.
Also async= doesn't mean much anymore.
So we need to wrap the callback and look at the return of the handle call to log all the possible outcomes:
- handle == false then
log("XX r=%s")
- handle == true, callback complete then
log("<< r=%s async=false ...
- handle == true, callback not complete then
log("|| r=%s async=true ...
In the callback, it should also check if handling has exited and if so it would need to log("<< r=%s ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.. but could have a bit more javadoc
private boolean handlingCompleted() | ||
{ | ||
//test if the request is still being handled or not | ||
return !_handling.compareAndSet(true, false); | ||
} | ||
|
||
private void callbackCompleted(Throwable throwable) | ||
{ | ||
if (_handling.compareAndSet(true, false)) | ||
log("<< r=%s async=false %d %s%n%s", findRequestName(_request), _response.getStatus(), (throwable == null ? "" : throwable.toString()), _response.getHeaders()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc on these methods would be helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the implementation to a) be more correct b) clearer and c) added more javadoc.
This is an alternate solution to debug logging using the
DebugHandler
class instead of theeeX
DebugListener
classes (as per PR #12231).The problem with #12231 is that all
DebugListeners
will share the same log file, which will lead to contention and sequencing problems. The solution would be to ensure that each context uses its own log, however, at the point in time at which the debug log is configured, nothing reasonably identifying is known about the context to which it is being applied. This is because theeeX-debug
modules are applied before a context xml file that would configure identifying info about that context, such as the context path or the location of the war being deployed.This PR takes a different approach, and uses a single
DebugHandler
inserted into the handler list instead. This guarantees proper locking of debug log file entries. I've enhanced the output of it so it more closely resembles the output of theDebugListener
. One notable omission in the logging is the identity of the context of the request being logged. This is because at the point in time that the DebugHandler executes we have not yet picked which context the request will be routed to.Fixes: #12191