-
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
Fixes #11072 - Jetty 12: CompleteCallbackHandler #11786
Fixes #11072 - Jetty 12: CompleteCallbackHandler #11786
Conversation
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>
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 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
if (lockedCompleteCallback()) | ||
return; | ||
|
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.
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.
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.
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.
...e/jetty-server/src/main/java/org/eclipse/jetty/server/handler/CallbackCompletionHandler.java
Outdated
Show resolved
Hide resolved
...e/jetty-server/src/main/java/org/eclipse/jetty/server/handler/CallbackCompletionHandler.java
Outdated
Show resolved
Hide resolved
...e/jetty-server/src/main/java/org/eclipse/jetty/server/handler/CallbackCompletionHandler.java
Outdated
Show resolved
Hide resolved
...e/jetty-server/src/main/java/org/eclipse/jetty/server/handler/CallbackCompletionHandler.java
Outdated
Show resolved
Hide resolved
@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 😄 |
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.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 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?
...e/jetty-server/src/main/java/org/eclipse/jetty/server/handler/CallbackCompletionHandler.java
Outdated
Show resolved
Hide resolved
...e/jetty-server/src/main/java/org/eclipse/jetty/server/handler/CallbackCompletionHandler.java
Outdated
Show resolved
Hide resolved
...e/jetty-server/src/main/java/org/eclipse/jetty/server/handler/CallbackCompletionHandler.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpChannelState.java
Show resolved
Hide resolved
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>
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.