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

Auto-boxing null Integer to long causing NPE #24

Merged

Conversation

kmbotts
Copy link

@kmbotts kmbotts commented Nov 24, 2019

Issue #4, NPE when short-polling a virtual queue

Description of changes:
Appears that the ReceiveMessageRequest.waitTimeSeconds is type Integer, so it will be null if not provided. The Completable future get timeout seconds is long type. So the NPE is a result of the auto-boxing of Integer to long which isn't clear as it's happening under the hood in the JVM.

Added check for null and removed implicit auto-boxing by calling longValue() method on Integer object.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@robin-aws
Copy link
Contributor

Thanks for the fix! Would you be able to add a quick unit test for this case?

@kmbotts
Copy link
Author

kmbotts commented Dec 26, 2019

Thanks for the fix! Would you be able to add a quick unit test for this case?

Things are a little hectic at work and the holidays are draining. So maybe after all that I can put a little something together.

@kmbotts
Copy link
Author

kmbotts commented Jan 3, 2020

@robin-aws , I have added the unit test. I just copied the existing test case and modified it to send a null WaitTimeoutSeconds on ReceiveMessageRequest and asserted that it worked. I catch NPE if it occurs. As a sanity check, I tested the negative test case by reverting my fix to ensure it failed as expected. So this should be adequate.

@robin-aws
Copy link
Contributor

Great, appreciate it! Thanks for the contribution!

@robin-aws robin-aws merged commit 87266b9 into awslabs:master Jan 3, 2020
@kmbotts kmbotts deleted the NPE-when-short-polling-a-virtual-queue branch January 3, 2020 21:16
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.

2 participants