Skip to content
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

Open
wants to merge 13 commits into
base: jetty-12.0.x
Choose a base branch
from

Conversation

janbartel
Copy link
Contributor

This is an alternate solution to debug logging using the DebugHandler class instead of the eeX 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 the eeX-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 the DebugListener. 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.

Copy link
Contributor

@gregw gregw left a 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.

Comment on lines 102 to 104
[[eeN-debug]]
== Module `{ee-all}-debug`
include::{jetty-home}/modules/ee10-debug.mod[tags=description]
Copy link
Contributor

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());
Copy link
Contributor

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 ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants