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

com.rabbitmq.client.RpcClient incorrectly deals with wrong/missing correlationId #5

Closed
bradleypeabody opened this issue Jan 11, 2013 · 1 comment
Milestone

Comments

@bradleypeabody
Copy link
Contributor

Using version 3.0.1:

In com.rabbitmq.client.RpcClient, around line 197, there's this function:

            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(body);                    
                }
            }

The issue is, 'blocker' might be null - if we get a reply to an old request that we no longer know about. The result is blocker.set(body) throws a NullPointerException and the message is then marked for retry and goes back in the queue and it creates an infinite loop.

We fixed this by replacing:

                    blocker.set(body);

with:

                    if (blocker != null) {
                        blocker.set(body);
                    } else {
                        logger.warn("blocking cell was null, ignoring response for it");
                    }

To reproduce - just resend any old jsonrpc reply message that was created by an earlier client and you'll see it NPE.

In our testing, we ran into this when we had a call that was issued once every 15 seconds or so, and took a few seconds to complete. If we restarted the client while the server was still processing a message, we'd end up with that stray reply stuck in the queue - and the new client endlessing NPEing in a loop.

@michaelklishin
Copy link
Member

We are cleaning up issues in preparation to moving to GitHub. Please let us know if this is still relevant.

@dumbbell dumbbell added this to the n/a milestone Mar 23, 2015
stream-iori pushed a commit to stream-iori/rabbitmq-java-client that referenced this issue Mar 20, 2022
Add travis ci badge and license badge to readme.
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

No branches or pull requests

3 participants