GH-9623: Fix ThreadStatePropagationChannelInterceptor for concurrency
Fixes: #9623 Issue link: https://github.com/spring-projects/spring-integration/issues/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 **Auto-cherry-pick to `6.3.x` & `6.2.x`**
This commit is contained in:
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.integration.channel.interceptor;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import io.micrometer.common.lang.Nullable;
|
||||
|
||||
@@ -104,14 +104,14 @@ public abstract class ThreadStatePropagationChannelInterceptor<S> implements Exe
|
||||
private final Queue<Object> stateQueue;
|
||||
|
||||
MessageWithThreadState(Message<?> message, Object state) {
|
||||
this(message, new LinkedList<>());
|
||||
this(message, new LinkedBlockingQueue<>());
|
||||
this.stateQueue.add(state);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private MessageWithThreadState(Message<?> message, Queue<Object> stateQueue) {
|
||||
this.message = (Message<Object>) message;
|
||||
this.stateQueue = new LinkedList<>(stateQueue);
|
||||
this.stateQueue = new LinkedBlockingQueue<>(stateQueue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user