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

Issue #9476 - Fix 9.4.51 NullPointerException #9932

Closed

Conversation

sid-evolphin
Copy link

@sid-evolphin sid-evolphin commented Jun 20, 2023

#9476
Added a null check for the Callback parameter in o.e.j.iAbstractConnection.failedCallback(Callback, Throwable) so that the subsequent code-flow is not aborted; while the root cause may be ascertained in case debug logging is enabled.

Further, in the case of a RejectedExecutionException when submitting the failCallback, the Runnable is run instead of directly invoking the Callback, so that exceptions in the Callback do not abort the synchronous code-flow.

Added a null check for the Callback parameter in o.e.j.iAbstractConnection.failedCallback(Callback, Throwable) so that the subsequent code-flow is not aborted; while the root cause may be ascertained in case debug logging is enabled.

Further, in the case of a RejectedExecutionException when submitting the failCallback, the Runnable is run instead of directly invoking the Callback, so that exceptions in the Callback do not abort the synchronous code-flow.
@sid-evolphin sid-evolphin changed the title Fix 9.4.51 NullPointerException #9476 Issue #9476 - Fix 9.4.51 NullPointerException Jun 20, 2023
@sid-evolphin sid-evolphin marked this pull request as ready for review June 20, 2023 08:07
@gregw gregw linked an issue Jun 20, 2023 that may be closed by this pull request
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 don't think this is the right solution. It is ignoring a null callback that should never have been created/executed.

Instead, I think the fix should be in onCompleteSuccess and onCompleteFailure on org.eclipse.jetty.server.HttpConnection.SendCallback. Both of these methods should call release() and if they get null back, then do no more.

I can see other problems there (those methods are not truly atomic), but we are not going to entirely fix jetty-9.4.

…lback

1. Fixed the usages of `Callback` returned by `o.e.j.s.HttpConnection.SendCallback.release()` to check for `null` before invoking the `failedCallback(Callback, Throwable)` or `succeeded()` methods.

2. Also, added a try-finally block around the Callback invocations in order to ensure that shutdownOutput will get performed irrespective of whether they end up throwing any exception.
…w feedback

Partially reverted `o.e.j.i.AbstractConnection.failedCallback(Callback, Throwable)` to not have a null check for the `Callback` parameter, based on review feedback from @gregw.

This avoids changing the contract of the method parameter (from `@NonNull` to `@Nullable`).
@sid-evolphin
Copy link
Author

Thank you very much @gregw for the review and comments.

  • I have incorporated your suggested changes to the methods in o.e.j.s.HttpConnection.SendCallback that use release() which may potentially return a null Callback.
    • They also now have try-finally blocks to ensure that shutdownOutput() does get invoked even if there is an exception in the callback.
  • I have reverted the null check in o.e.j.i.AbstractConnection.failedCallback(Callback, Throwable) to maintain the method parameter contract of @NonNull.

Please re-review this PR. Thank you very much.

@sid-evolphin sid-evolphin requested a review from gregw June 20, 2023 12:32
@gregw
Copy link
Contributor

gregw commented Jun 20, 2023

Replaced by #9935

@gregw gregw closed this Jun 20, 2023
@sid-evolphin
Copy link
Author

Replaced by #9935

Thanks a lot @gregw . I'm glad you are fixing the root cause.

@sid-evolphin sid-evolphin deleted the fix/jetty-9.4.x/9476 branch June 20, 2023 14:28
@sid-evolphin sid-evolphin restored the fix/jetty-9.4.x/9476 branch June 20, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onCompleteFailure called multiple times
2 participants