Skip to content

RpcClient.java get NullPointerException #306

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

Closed
tvd12 opened this issue Sep 14, 2017 · 2 comments
Closed

RpcClient.java get NullPointerException #306

tvd12 opened this issue Sep 14, 2017 · 2 comments
Assignees
Milestone

Comments

@tvd12
Copy link

tvd12 commented Sep 14, 2017

In RpcClient.java we have:

          @Override
            public void handleDelivery(String consumerTag,
                                       Envelope envelope,
                                       AMQP.BasicProperties properties,
                                       byte[] body)
                    throws IOException {
                synchronized (_continuationMap) {
                    String replyId = properties.getCorrelationId();
                    BlockingCell<Object> blocker = _continuationMap.get(replyId);
                    _continuationMap.remove(replyId);
                    blocker.set(new Response(consumerTag, envelope, properties, body));
                }
            }

Because, we haven't checked blocker != null, so we get NullPointerException
And
Why we don't use:

 BlockingCell<Object> blocker = _continuationMap.remove(replyId);

instead of

BlockingCell<Object> blocker = _continuationMap.get(replyId);
                    _continuationMap.remove(replyId);
@acogoluegnes
Copy link
Contributor

@tvd12 Can you provide a code snippet that reliably reproduce the NullPointerException? I don't mind making the code more defensive, but I'd like to do it for a reason.

@tvd12
Copy link
Author

tvd12 commented Sep 18, 2017

I have seen NullPointerException when RpcServer received two request with duplicate correlationId from client. It's a mistake from me, but I think anyone are easy to make that mistake, and if we throw an exception with detail message, it's a help for many developers.
Sorry, I fixed a lot of source code and now I don't want rollback them, so I can't provide to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants