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

NPE in AbstractMetricsCollector when channel limit is exceeded #944

Closed
Dav1dde opened this issue Jan 26, 2023 · 0 comments
Closed

NPE in AbstractMetricsCollector when channel limit is exceeded #944

Dav1dde opened this issue Jan 26, 2023 · 0 comments
Labels
Milestone

Comments

@Dav1dde
Copy link

Dav1dde commented Jan 26, 2023

ChannelManager#createChannel can return null when it runs out of free channels, the JavaDoc of AMQConnection#createChannel also says it may return null.

The following code in createChannel() and createChannel(int channelNumber)

Channel channel = cm.createChannel(this, channelNumber);
metricsCollector.newChannel(channel);
return channel;

leads to an NPE in AbstractMetricsCollector#newChannel:

incrementChannelCount(channel);
channel.addShutdownListener(cause -> closeChannel(channel));
connectionState(channel.getConnection()).channelState.put(channel.getChannelNumber(), new ChannelState(channel));

channel.addShutdownListener will fail with the NPE.

We've observed this through logs in one of our production services:

01-25 12:52:30 INFO  c.r.c.impl.AbstractMetricsCollector - Error while computing metrics in newChannel: Cannot invoke "com.rabbitmq.client.Channel.addShutdownListener(com.rabbitmq.client.ShutdownListener)" because "channel" is null
@michaelklishin michaelklishin changed the title NPE in AbstractMetricsCollector NPE in AbstractMetricsCollector when channel limit is exceeded Jan 26, 2023
@acogoluegnes acogoluegnes added this to the 5.17.0 milestone Jan 27, 2023
acogoluegnes added a commit that referenced this issue Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants