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

Avoid NPE potentially caused by race condition #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jdpgrailsdev
Copy link

Periodically, we are seeing a java.lang.NullPointerException with the following stack trace:

…t.spy.memcached.protocol.TCPMemcachedNodeImpl.toString (TCPMemcachedNodeImpl.java:488)
java.util.Formatter$FormatSpecifier.printString (Formatter.java:2886)
java.util.Formatter$FormatSpecifier.print (Formatter.java:2763)
java.util.Formatter.format (Formatter.java:2520)
java.util.Formatter.format (Formatter.java:2455)
java.lang.String.format (String.java:2940)
net.spy.memcached.compat.log.AbstractLogger.info (AbstractLogger.java:161)
net.spy.memcached.MemcachedConnection.handleIO (MemcachedConnection.java:716)
net.spy.memcached.MemcachedConnection.handleIO (MemcachedConnection.java:450)
net.spy.memcached.MemcachedConnection.run (MemcachedConnection.java:1457)

As far as I can tell, there must be some sort of race going on where the second call to getSk() returns null even after the first check passes, causing the de-reference of the isValid() method to throw the NPE. I am wondering if the real fix is to put some sort of lock around the SK or have the getSk() method return a copy to avoid this issue. It's unclear what the impact is when this happens, but I suspect it is causing an operation to fail/not be executed because the runtime exception.

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.

1 participant