call dispatch only when stepBuffer returns true #145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
while using the library in one of our projects we noticed a null pointer exception occuring in the XMemcachedClient:
https://github.com/killme2008/xmemcached/blob/master/src/main/java/net/rubyeye/xmemcached/XMemcachedClient.java#L1215
This happens because the
TextGetCommand.result
is not ready yet when theXMemcachedClient.reduceResult
method is invoked.The result is not ready because a single command may reduce the countdown latch more than once by calling
dispatch
method inside theTextGetCommand.decode
method.The issue is in this part of the code:
It calls
dispatch
when it encountersE
followed byN
and returns the result of checking whether the buffer contains 5 or more elements. However if there are less than 5 elements remaining in the buffer then the result will befalse
and thedecode
method will be called again, entering the same condition and callingdispatch
second time.To avoid this the pull request changes this part of the code to call
dispatch
only when there are 5 or more elements in the buffer.