Skip to content

Commit 6d64b6e

Browse files
artembilanspring-builds
authored andcommitted
GH-9623: Fix ThreadStatePropagationChannelInterceptor for concurrency
Fixes: #9623 Issue link: #9623 The `ConcurrentModificationException` is thrown from the `ThreadStatePropagationChannelInterceptor.MessageWithThreadState.stateQueue` which is a not thread-safe `LinkedList` * Fix `ThreadStatePropagationChannelInterceptor.MessageWithThreadState.stateQueue` to be a `LinkedBlockingQueue` instead (cherry picked from commit ba57ee8)
1 parent 16f5824 commit 6d64b6e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ThreadStatePropagationChannelInterceptor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package org.springframework.integration.channel.interceptor;
1818

19-
import java.util.LinkedList;
2019
import java.util.Queue;
20+
import java.util.concurrent.LinkedBlockingQueue;
2121

2222
import io.micrometer.common.lang.Nullable;
2323

@@ -105,14 +105,14 @@ private static final class MessageWithThreadState implements Message<Object>, Me
105105
private final Queue<Object> stateQueue;
106106

107107
MessageWithThreadState(Message<?> message, Object state) {
108-
this(message, new LinkedList<>());
108+
this(message, new LinkedBlockingQueue<>());
109109
this.stateQueue.add(state);
110110
}
111111

112112
@SuppressWarnings("unchecked")
113113
private MessageWithThreadState(Message<?> message, Queue<Object> stateQueue) {
114114
this.message = (Message<Object>) message;
115-
this.stateQueue = new LinkedList<>(stateQueue);
115+
this.stateQueue = new LinkedBlockingQueue<>(stateQueue);
116116
}
117117

118118
@Override

0 commit comments

Comments
 (0)