-
Notifications
You must be signed in to change notification settings - Fork 50
bug(listener): Add null check for content before updating response size #127
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
base: master
Are you sure you want to change the base?
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR adds a null check for the ByteBuffer content in HttpServerChannelListener.onResponseWrite to prevent NullPointerExceptions when content is null, ensuring response size metrics are only updated when content exists. Sequence diagram for updated response size update in onResponseWritesequenceDiagram
participant Listener as HttpServerChannelListener
participant Req as Request
participant Size as AtomicLong
participant Content as ByteBuffer
Listener->>Req: getAttribute(RESPONSE_CONTENT_SIZES_ATTRIBUTE)
alt RESPONSE_CONTENT_SIZES_ATTRIBUTE is null
Listener->>Req: setAttribute(RESPONSE_CONTENT_SIZES_ATTRIBUTE, new AtomicLong(0L))
end
alt content != null
Listener->>Req: getAttribute(RESPONSE_CONTENT_SIZES_ATTRIBUTE)
Listener->>Size: addAndGet(content.remaining())
else content == null
Note over Listener: skips response size update
end
Class diagram for updated HttpServerChannelListener.onResponseWrite methodclassDiagram
class HttpServerChannelListener {
+onResponseWrite(Request request, boolean last, ByteBuffer content)
}
class Request {
+getAttribute(String key)
+setAttribute(String key, Object value)
}
class AtomicLong {
+addAndGet(long delta)
}
HttpServerChannelListener --> Request
Request --> AtomicLong
%% Highlight: onResponseWrite now checks if content != null before updating response size
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 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.
Thank you for the fix
I have never seen this error anytime before. Wondering if this is a byproduct of upgrading to java 17 |
Sometimes Presto can run into this error:
This PR will resolve it by adding a null check.