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

Fixes #11072 - Jetty 12: CompleteCallbackHandler #11786

Merged

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented May 13, 2024

Introduced CallbackCompletionHandler.

CallbackCompletionHandler is a troubleshooting Handler that helps to identify those cases where the Handler/Request/Response APIs are used improperly.

In particular, it tracks the events described in CallbackCompletionHandler.Listener, such as the Handler callback not completed, or blocking demand callback, or a write callback not completed, etc.

It also provides dump() capabilities, so the current requests and their state is dumped to help troubleshooting.

CallbackCompletionHandler is a troubleshooting Handler that helps to identify those cases where the Handler/Request/Response APIs are used improperly.

In particular, it tracks the events described in CallbackCompletionHandler.Listener, such as the Handler callback not completed, or blocking demand callback, or a write callback not completed, etc.

It also provides dump() capabilities, so the current requests and their state is dumped to help troubleshooting.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet requested review from gregw and lorban May 13, 2024 21:19
@sbordet sbordet linked an issue May 13, 2024 that may be closed by this pull request
@sbordet
Copy link
Contributor Author

sbordet commented May 13, 2024

@gregw @lorban happy to discuss this new Handler, as it is a magnet for features.

Still lacking: handling of exceptions thrown by handle() and *.adoc documentation.

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 think at the very least we need to test:

  • demand calls made within a demand callback
  • demand calls made within a write succeeded callback
  • write calls made within a demand callback
  • write calls made within a write succeeded callback

It would be interesting to see how those look in a dump when:

  • the inner demand/write is pending and the outer callback has not returned
  • the inner demand/write able to complete, but the outer callback has not returned

Comment on lines +1479 to +1481
if (lockedCompleteCallback())
return;

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain this change? Looks like you are fixing some unrelated issue?

It seams wrong to take action before checking for pending demand and write calls?

The boolean on that method also feels the wrong way around.

Copy link
Contributor Author

@sbordet sbordet May 14, 2024

Choose a reason for hiding this comment

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

The old code produces an NPE (as httpChannelState is null) when an application returns false from handle(), and then mistakenly completes the callback (which, at that point, is already completed by Jetty producing a 404).

BY doing the early check on whether the callback is already completed, we avoid the NPE.

@sbordet
Copy link
Contributor Author

sbordet commented May 14, 2024

@gregw I have written tests for demand within demand and write within write, because now they are implemented as queues.

The other cases seem "normal" ones that are covered in behavior by other tests.

I don't think we should test the dump output too much, as likely the format will change; I need a little more convincing that shows it is a good idea to test dump format output 😄

@sbordet sbordet requested a review from gregw May 15, 2024 07:24
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
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 think this is pretty close.. we should get it merged before adding too many more features.

But we need the right name before merging. The current name means nothing to me... I have a few suggestions?

Added handling of exceptions thrown by handle().

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet requested review from lorban and gregw May 15, 2024 15:01
@sbordet sbordet merged commit a4c2970 into jetty-12.0.x May 19, 2024
10 checks passed
@sbordet sbordet deleted the fix/jetty-12/11072/introduce-callback-completion-handler branch May 19, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Jetty 12: CompleteCallbackHandler
3 participants