Skip to content

Commit 274cd77

Browse files
author
David R. MacIver
committed
complete failure in the implementation of IntAllocator.flush() lead to being unable to create a channel with a previously explicitly^Csed number that had since been closed
1 parent f7eb76d commit 274cd77

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/com/rabbitmq/utility/IntAllocator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ public boolean reserve(int id){
132132
return false;
133133
}
134134

135-
private void flush(){
135+
public void flush(){
136136
if(unsortedCount == 0) return;
137137

138-
Arrays.sort(unsorted);
138+
Arrays.sort(unsorted, 0, unsortedCount);
139139

140140
ListIterator<Interval> it = intervals.listIterator();
141141

@@ -145,7 +145,7 @@ private void flush(){
145145
while((i < unsortedCount - 1) && (unsorted[i + 1] == unsorted[i] + 1))
146146
i++;
147147

148-
Interval interval = new Interval(start, i);
148+
Interval interval = new Interval(unsorted[start], unsorted[i]);
149149

150150
// Scan to an appropriate point in the list to insert this interval
151151
// this may well be the end

test/src/com/rabbitmq/client/test/ChannelNumberAllocationTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,9 @@ public void testManualAllocationDoesntBreakThings() throws Exception{
7474
Channel ch = connection.createChannel();
7575
assertNotNull(ch);
7676
}
77+
78+
public void testReuseManuallyAllocatedChannelNumber() throws Exception{
79+
connection.createChannel(1).close();
80+
assertNotNull(connection.createChannel(1));
81+
}
7782
}

0 commit comments

Comments
 (0)