Skip to content

Commit d7e0b9d

Browse files
committed
AMQP-828: Fix race, removing the shutdown listener
The channel might close between the `isOpen()` test and removing the listener.
1 parent d5663f4 commit d7e0b9d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,12 @@ private Delivery consumeDelivery(Channel channel, String queueName, long timeout
12351235
&& channel.isOpen()) {
12361236
cancelConsumerQuietly(channel, consumer);
12371237
}
1238-
channel.removeShutdownListener(shutdownListener);
1238+
try {
1239+
channel.removeShutdownListener(shutdownListener);
1240+
}
1241+
catch (Exception e) {
1242+
// NOSONAR - channel might have closed.
1243+
}
12391244
}
12401245
return delivery;
12411246
}

0 commit comments

Comments
 (0)