File tree 2 files changed +15
-9
lines changed
src/main/java/com/rabbitmq/client/impl
2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 1
- // Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
1
+ // Copyright (c) 2007-2023 VMware, Inc. or its affiliates. All rights reserved.
2
2
//
3
3
// This software, the RabbitMQ Java client library, is triple-licensed under the
4
4
// Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2
@@ -605,7 +605,9 @@ public Channel createChannel(int channelNumber) throws IOException {
605
605
ChannelManager cm = _channelManager ;
606
606
if (cm == null ) return null ;
607
607
Channel channel = cm .createChannel (this , channelNumber );
608
- metricsCollector .newChannel (channel );
608
+ if (channel != null ) {
609
+ metricsCollector .newChannel (channel );
610
+ }
609
611
return channel ;
610
612
}
611
613
@@ -616,7 +618,9 @@ public Channel createChannel() throws IOException {
616
618
ChannelManager cm = _channelManager ;
617
619
if (cm == null ) return null ;
618
620
Channel channel = cm .createChannel (this );
619
- metricsCollector .newChannel (channel );
621
+ if (channel != null ) {
622
+ metricsCollector .newChannel (channel );
623
+ }
620
624
return channel ;
621
625
}
622
626
Original file line number Diff line number Diff line change @@ -72,12 +72,14 @@ public void closeConnection(Connection connection) {
72
72
73
73
@ Override
74
74
public void newChannel (final Channel channel ) {
75
- try {
76
- incrementChannelCount (channel );
77
- channel .addShutdownListener (cause -> closeChannel (channel ));
78
- connectionState (channel .getConnection ()).channelState .put (channel .getChannelNumber (), new ChannelState (channel ));
79
- } catch (Exception e ) {
80
- LOGGER .info ("Error while computing metrics in newChannel: " + e .getMessage ());
75
+ if (channel != null ) {
76
+ try {
77
+ incrementChannelCount (channel );
78
+ channel .addShutdownListener (cause -> closeChannel (channel ));
79
+ connectionState (channel .getConnection ()).channelState .put (channel .getChannelNumber (), new ChannelState (channel ));
80
+ } catch (Exception e ) {
81
+ LOGGER .info ("Error while computing metrics in newChannel: " + e .getMessage ());
82
+ }
81
83
}
82
84
}
83
85
You can’t perform that action at this time.
0 commit comments