Skip to content

Commit 894a234

Browse files
committed
fix the race condition in concurrency operation
1 parent 76fe964 commit 894a234

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

sdk/src/main/java/software/amazon/lambda/durable/operation/BaseDurableOperation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ protected Operation waitForOperationCompletion() {
188188
// is between `isOperationCompleted` and `thenRun`.
189189
// If this operation is a branch/iteration of a ConcurrencyOperation (map or parallel), the branches/iterations
190190
// must be completed sequentially to avoid race conditions.
191-
synchronized (parentOperation == null ? completionFuture : parentOperation) {
191+
synchronized (parentOperation == null ? this : parentOperation) {
192192
if (!isOperationCompleted()) {
193193
// Operation not done yet
194194
logger.trace(
@@ -295,7 +295,7 @@ protected void markAlreadyCompleted() {
295295
private void markCompletionFutureCompleted() {
296296
// It's important that we synchronize access to the future, otherwise the processing could happen
297297
// on someone else's thread and cause a race condition.
298-
synchronized (parentOperation == null ? completionFuture : parentOperation) {
298+
synchronized (parentOperation == null ? this : parentOperation) {
299299
// Completing the future here will also run any other completion stages that have been attached
300300
// to the future. In our case, other contexts may have attached a function to reactivate themselves,
301301
// so they will definitely have a chance to reactivate before we finish completing and deactivating

0 commit comments

Comments
 (0)