File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed
src/main/java/com/rabbitmq/client/impl Expand file tree Collapse file tree 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.
22//
33// This software, the RabbitMQ Java client library, is triple-licensed under the
44// Mozilla Public License 2.0 ("MPL"), the GNU General Public License version 2
@@ -605,7 +605,9 @@ public Channel createChannel(int channelNumber) throws IOException {
605605 ChannelManager cm = _channelManager ;
606606 if (cm == null ) return null ;
607607 Channel channel = cm .createChannel (this , channelNumber );
608- metricsCollector .newChannel (channel );
608+ if (channel != null ) {
609+ metricsCollector .newChannel (channel );
610+ }
609611 return channel ;
610612 }
611613
@@ -616,7 +618,9 @@ public Channel createChannel() throws IOException {
616618 ChannelManager cm = _channelManager ;
617619 if (cm == null ) return null ;
618620 Channel channel = cm .createChannel (this );
619- metricsCollector .newChannel (channel );
621+ if (channel != null ) {
622+ metricsCollector .newChannel (channel );
623+ }
620624 return channel ;
621625 }
622626
Original file line number Diff line number Diff line change @@ -72,12 +72,14 @@ public void closeConnection(Connection connection) {
7272
7373 @ Override
7474 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+ }
8183 }
8284 }
8385
You can’t perform that action at this time.
0 commit comments