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
KAFKA-6233 :Removed unnecessary null check #4232
Conversation
FAILURE |
SUCCESS |
1 similar comment
SUCCESS |
Failure is unrelated. |
@@ -34,7 +34,7 @@ public void configure(Map<String, ?> configs, boolean isKey) { | |||
Object encodingValue = configs.get(propertyName); | |||
if (encodingValue == null) | |||
encodingValue = configs.get("serializer.encoding"); | |||
if (encodingValue != null && encodingValue instanceof String) |
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.
encodingValue
can still be null right, as configs.get(..)
could still return a null.
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.
yes encoding value can be null but the instanceof operator does not return
null pointer exception for encodingValue==null.
Instead if encodingValue==null, (encodingValue instanceof String) returns
false which is the desired behavior.
Thanks for the quick reply.
yes encoding value can be null but the instanceof operator does not return
null pointer exception for encodingValue==null.
Instead if encodingValue==null, (encodingValue instanceof String) returns
false which is the desired behavior.
Thanks for the quick reply.
…On Sat, Nov 18, 2017 at 2:58 PM, Guozhang Wang ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In clients/src/main/java/org/apache/kafka/common/serialization/
StringSerializer.java
<#4232 (comment)>:
> @@ -34,7 +34,7 @@ public void configure(Map<String, ?> configs, boolean isKey) {
Object encodingValue = configs.get(propertyName);
if (encodingValue == null)
encodingValue = configs.get("serializer.encoding");
- if (encodingValue != null && encodingValue instanceof String)
encodingValue can still be null right, as configs.get(..) could still
return a null.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4232 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AekdFSfo0toZQRRz_Kt9dvvr0in-2Mg3ks5s32EEgaJpZM4QjJVZ>
.
|
Removed unnecessary null check
if (encodingValue != null && encodingValue instanceof String)
null instanceof String returns false hence replaced the check with
if (encodingValue instanceof String)
Committer Checklist (excluded from commit message)