Skip to content

Commit aaff1cc

Browse files
AutorecoveringConnection: clean up bindings of deleted exchanges
so that they (the bindings) do not reappear after connection recovery. Noticed while working on ruby-amqp/bunny#704.
1 parent fbaceb6 commit aaff1cc

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/main/java/com/rabbitmq/client/impl/recovery/AutorecoveringConnection.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,12 @@ void recordExchange(String exchange, RecordedExchange x) {
10951095

10961096
void deleteRecordedExchange(String exchange) {
10971097
this.recordedExchanges.remove(exchange);
1098-
Set<RecordedBinding> xs = this.removeBindingsWithDestination(exchange);
1099-
for (RecordedBinding b : xs) {
1098+
Set<RecordedBinding> xs1 = this.removeBindingsWithDestination(exchange);
1099+
for (RecordedBinding b : xs1) {
1100+
this.maybeDeleteRecordedAutoDeleteExchange(b.getSource());
1101+
}
1102+
Set<RecordedBinding> xs2 = this.removeBindingsWithSource(exchange);
1103+
for (RecordedBinding b : xs2) {
11001104
this.maybeDeleteRecordedAutoDeleteExchange(b.getSource());
11011105
}
11021106
}
@@ -1173,6 +1177,20 @@ Set<RecordedBinding> removeBindingsWithDestination(String s) {
11731177
return result;
11741178
}
11751179

1180+
Set<RecordedBinding> removeBindingsWithSource(String s) {
1181+
final Set<RecordedBinding> result = new LinkedHashSet<>();
1182+
synchronized (this.recordedBindings) {
1183+
for (Iterator<RecordedBinding> it = this.recordedBindings.iterator(); it.hasNext(); ) {
1184+
RecordedBinding b = it.next();
1185+
if (b.getSource().equals(s)) {
1186+
it.remove();
1187+
result.add(b);
1188+
}
1189+
}
1190+
}
1191+
return result;
1192+
}
1193+
11761194
public Map<String, RecordedQueue> getRecordedQueues() {
11771195
return recordedQueues;
11781196
}

0 commit comments

Comments
 (0)