Skip to content

Commit ebc3e29

Browse files
Merge pull request #695 from wangqiandeniangniang/main_friendly_tips
Be more defensive about provided channelMax values
2 parents d832091 + 0a4f08b commit ebc3e29

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/com/rabbitmq/client/impl/ChannelManager.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public class ChannelManager {
3939

4040
/** Monitor for <code>_channelMap</code> and <code>channelNumberAllocator</code> */
4141
private final Object monitor = new Object();
42-
/** Mapping from <code><b>1.._channelMax</b></code> to {@link ChannelN} instance */
43-
private final Map<Integer, ChannelN> _channelMap = new HashMap<Integer, ChannelN>();
44-
private final IntAllocator channelNumberAllocator;
42+
/** Mapping from <code><b>1.._channelMax</b></code> to {@link ChannelN} instance */
43+
private final Map<Integer, ChannelN> _channelMap = new HashMap<Integer, ChannelN>();
44+
private final IntAllocator channelNumberAllocator;
4545

4646
private final ConsumerWorkService workService;
4747

@@ -70,6 +70,8 @@ public ChannelManager(ConsumerWorkService workService, int channelMax, ThreadFac
7070

7171

7272
public ChannelManager(ConsumerWorkService workService, int channelMax, ThreadFactory threadFactory, MetricsCollector metricsCollector) {
73+
if (channelMax < 0)
74+
throw new IllegalArgumentException("create ChannelManager: 'channelMax' must be greater or equal to 0.");
7375
if (channelMax == 0) {
7476
// The framing encoding only allows for unsigned 16-bit integers
7577
// for the channel number

0 commit comments

Comments
 (0)