18
18
import com .rabbitmq .client .*;
19
19
import com .rabbitmq .client .impl .AMQCommand ;
20
20
import com .rabbitmq .client .impl .recovery .Utils .IoTimeoutExceptionRunnable ;
21
+ import com .rabbitmq .utility .Utility ;
21
22
import org .slf4j .Logger ;
22
23
import org .slf4j .LoggerFactory ;
23
24
@@ -39,11 +40,11 @@ public class AutorecoveringChannel implements RecoverableChannel {
39
40
40
41
private volatile RecoveryAwareChannelN delegate ;
41
42
private volatile AutorecoveringConnection connection ;
42
- private final List <ShutdownListener > shutdownHooks = new CopyOnWriteArrayList <ShutdownListener >();
43
- private final List <RecoveryListener > recoveryListeners = new CopyOnWriteArrayList <RecoveryListener >();
44
- private final List <ReturnListener > returnListeners = new CopyOnWriteArrayList <ReturnListener >();
45
- private final List <ConfirmListener > confirmListeners = new CopyOnWriteArrayList <ConfirmListener >();
46
- private final Set <String > consumerTags = Collections .synchronizedSet (new HashSet <String >());
43
+ private final List <ShutdownListener > shutdownHooks = new CopyOnWriteArrayList <>();
44
+ private final List <RecoveryListener > recoveryListeners = new CopyOnWriteArrayList <>();
45
+ private final List <ReturnListener > returnListeners = new CopyOnWriteArrayList <>();
46
+ private final List <ConfirmListener > confirmListeners = new CopyOnWriteArrayList <>();
47
+ private final Set <String > consumerTags = Collections .synchronizedSet (new HashSet <>());
47
48
private int prefetchCountConsumer ;
48
49
private int prefetchCountGlobal ;
49
50
private boolean usesPublisherConfirms ;
@@ -100,8 +101,8 @@ private void executeAndClean(IoTimeoutExceptionRunnable callback) throws IOExcep
100
101
try {
101
102
callback .run ();
102
103
} finally {
103
- for (String consumerTag : consumerTags ) {
104
- this .connection . deleteRecordedConsumer (consumerTag );
104
+ for (String consumerTag : Utility . copy ( consumerTags ) ) {
105
+ this .deleteRecordedConsumer (consumerTag );
105
106
}
106
107
this .connection .unregisterChannel (this );
107
108
}
@@ -644,10 +645,7 @@ public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProp
644
645
645
646
@ Override
646
647
public void basicCancel (String consumerTag ) throws IOException {
647
- RecordedConsumer c = this .deleteRecordedConsumer (consumerTag );
648
- if (c != null ) {
649
- this .maybeDeleteRecordedAutoDeleteQueue (c .getQueue ());
650
- }
648
+ this .deleteRecordedConsumer (consumerTag );
651
649
delegate .basicCancel (consumerTag );
652
650
}
653
651
@@ -902,13 +900,12 @@ private void recordConsumer(String result,
902
900
this .connection .recordConsumer (result , consumer );
903
901
}
904
902
905
- private RecordedConsumer deleteRecordedConsumer (String consumerTag ) {
903
+ private void deleteRecordedConsumer (String consumerTag ) {
906
904
this .consumerTags .remove (consumerTag );
907
- return this .connection .deleteRecordedConsumer (consumerTag );
908
- }
909
-
910
- private void maybeDeleteRecordedAutoDeleteQueue (String queue ) {
911
- this .connection .maybeDeleteRecordedAutoDeleteQueue (queue );
905
+ RecordedConsumer c = this .connection .deleteRecordedConsumer (consumerTag );
906
+ if (c != null ) {
907
+ this .connection .maybeDeleteRecordedAutoDeleteQueue (c .getQueue ());
908
+ }
912
909
}
913
910
914
911
private void maybeDeleteRecordedAutoDeleteExchange (String exchange ) {
0 commit comments