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

KAFKA-6233 :Removed unnecessary null check #4232

Closed
wants to merge 1 commit into from

Conversation

sagarchavan3172
Copy link
Contributor

@sagarchavan3172 sagarchavan3172 commented Nov 18, 2017

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)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@asfgit
Copy link

asfgit commented Nov 18, 2017

FAILURE
7973 tests run, 5 skipped, 1 failed.
--none--

@asfgit
Copy link

asfgit commented Nov 18, 2017

SUCCESS
8081 tests run, 5 skipped, 0 failed.
--none--

1 similar comment
@asfgit
Copy link

asfgit commented Nov 18, 2017

SUCCESS
8081 tests run, 5 skipped, 0 failed.
--none--

@sagarchavan3172
Copy link
Contributor Author

Failure is unrelated.
This is my first PR for kafka.
@guozhangwang @dguy @bbejeck Can you please review? Thanks

@@ -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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@sagarchavan3172
Copy link
Contributor Author

sagarchavan3172 commented Nov 18, 2017 via email

@asfgit asfgit closed this in 83b8cf9 Nov 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants