Skip to content

Commit

Permalink
Attempt to fix race condition in the CachingConnectionFactory
Browse files Browse the repository at this point in the history
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
  • Loading branch information
artembilan committed Dec 6, 2024
1 parent ced72ed commit 162ef4a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,6 @@ private void refreshProxyConnection(ChannelCachingConnectionProxy connection) {
*/
@Override
public final void destroy() {
super.destroy();
resetConnection();
if (getContextStopped()) {
this.stopped = true;
this.connectionLock.lock();
Expand Down Expand Up @@ -890,6 +888,8 @@ public final void destroy() {
this.connectionLock.unlock();
}
}
super.destroy();
resetConnection();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
* @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";

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -41,9 +41,9 @@
* @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";

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -41,10 +41,10 @@
* @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";

Expand Down

0 comments on commit 162ef4a

Please sign in to comment.