Skip to content

Commit

Permalink
GH-9623: Fix ThreadStatePropagationChannelInterceptor for concurrency
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
artembilan authored and spring-builds committed Oct 31, 2024
1 parent 5c76a47 commit 34b6100
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -104,14 +104,14 @@ private static final class MessageWithThreadState implements Message<Object>, Me
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
Expand Down

0 comments on commit 34b6100

Please sign in to comment.