Skip to content

Commit 944c2f5

Browse files
adriannistormillems
authored andcommitted
Field eventsToDeliver is a LinkedList, i.e., not thread-safe. Accesses to field eventsToDeliver are protected by synchronization on itself, but not in 1 location.
1 parent 8e40275 commit 944c2f5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "bugfix",
3+
"category": "AWS SDK for Java v2",
4+
"description": "Fixing race condition in EventStreamAsyncResponseTransformer. Field eventsToDeliver is a LinkedList, i.e., not thread-safe. Accesses to field eventsToDeliver are protected by synchronization on itself, but not in 1 location."
5+
}

core/aws-core/src/main/java/software/amazon/awssdk/awscore/eventstream/EventStreamAsyncResponseTransformer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ public void onError(Throwable throwable) {
394394
@Override
395395
public void onComplete() {
396396
// Add the special on complete event to signal drainEvents to complete the subscriber
397-
eventsToDeliver.add(ON_COMPLETE_EVENT);
397+
synchronized (eventsToDeliver) {
398+
eventsToDeliver.add(ON_COMPLETE_EVENT);
399+
}
398400
drainEventsIfNotAlready();
399401
transformFuture.complete(null);
400402
}

0 commit comments

Comments
 (0)