Attempt to fix race condition in the CachingConnectionFactory
There is a logic in the `CachingConnectionFactory.destroy()` where we wait for `inFlightAsyncCloses`. However, it looks like we first close the main connection with all its channels. Therefore, we may end up with a `ConcurrentModificationException` when we iterate channels list for clean up, but in-flight requests still wait for their confirms, therefore they may come back to the cache meanwhile we are trying to clean up
This commit is contained in:
@@ -861,8 +861,6 @@ public class CachingConnectionFactory extends AbstractConnectionFactory
|
||||
*/
|
||||
@Override
|
||||
public final void destroy() {
|
||||
super.destroy();
|
||||
resetConnection();
|
||||
if (getContextStopped()) {
|
||||
this.stopped = true;
|
||||
this.connectionLock.lock();
|
||||
@@ -890,6 +888,8 @@ public class CachingConnectionFactory extends AbstractConnectionFactory
|
||||
this.connectionLock.unlock();
|
||||
}
|
||||
}
|
||||
super.destroy();
|
||||
resetConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -95,8 +95,8 @@ import com.rabbitmq.client.ConnectionFactory;
|
||||
* @since 1.1
|
||||
*
|
||||
*/
|
||||
@RabbitAvailable(queues = RabbitTemplatePublisherCallbacksIntegrationTests.ROUTE)
|
||||
public class RabbitTemplatePublisherCallbacksIntegrationTests {
|
||||
@RabbitAvailable(queues = RabbitTemplatePublisherCallbacksIntegration1Tests.ROUTE)
|
||||
public class RabbitTemplatePublisherCallbacksIntegration1Tests {
|
||||
|
||||
public static final String ROUTE = "test.queue.RabbitTemplatePublisherCallbacksIntegrationTests";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2022 the original author or authors.
|
||||
* Copyright 2016-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,9 +41,9 @@ import com.rabbitmq.client.Envelope;
|
||||
* @since 1.6
|
||||
*
|
||||
*/
|
||||
@RabbitAvailable(queues = { RabbitTemplatePublisherCallbacksIntegrationTests2.ROUTE,
|
||||
RabbitTemplatePublisherCallbacksIntegrationTests2.ROUTE2 })
|
||||
public class RabbitTemplatePublisherCallbacksIntegrationTests2 {
|
||||
@RabbitAvailable(queues = { RabbitTemplatePublisherCallbacksIntegration2Tests.ROUTE,
|
||||
RabbitTemplatePublisherCallbacksIntegration2Tests.ROUTE2 })
|
||||
public class RabbitTemplatePublisherCallbacksIntegration2Tests {
|
||||
|
||||
public static final String ROUTE = "test.queue.RabbitTemplatePublisherCallbacksIntegrationTests2";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2021 the original author or authors.
|
||||
* Copyright 2018-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,10 +41,10 @@ import com.rabbitmq.client.Channel;
|
||||
* @since 2.1
|
||||
*
|
||||
*/
|
||||
@RabbitAvailable(queues = { RabbitTemplatePublisherCallbacksIntegrationTests3.QUEUE1,
|
||||
RabbitTemplatePublisherCallbacksIntegrationTests3.QUEUE2,
|
||||
RabbitTemplatePublisherCallbacksIntegrationTests3.QUEUE3 })
|
||||
public class RabbitTemplatePublisherCallbacksIntegrationTests3 {
|
||||
@RabbitAvailable(queues = { RabbitTemplatePublisherCallbacksIntegration3Tests.QUEUE1,
|
||||
RabbitTemplatePublisherCallbacksIntegration3Tests.QUEUE2,
|
||||
RabbitTemplatePublisherCallbacksIntegration3Tests.QUEUE3 })
|
||||
public class RabbitTemplatePublisherCallbacksIntegration3Tests {
|
||||
|
||||
public static final String QUEUE1 = "synthetic.nack";
|
||||
|
||||
Reference in New Issue
Block a user