Skip to content

Commit

Permalink
Merge pull request #43699 from ravinperera00/issue_43654_4
Browse files Browse the repository at this point in the history
[2201.10.x] - Use Java exception to notify `cannot complete future twice`
  • Loading branch information
warunalakshitha authored Dec 11, 2024
2 parents 08131a6 + 9a7b611 commit 320722f
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
package io.ballerina.runtime.internal;

import io.ballerina.runtime.api.Future;
import io.ballerina.runtime.api.PredefinedTypes;
import io.ballerina.runtime.api.creators.ErrorCreator;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.internal.scheduling.Strand;
import io.ballerina.runtime.internal.values.MapValueImpl;

import java.util.concurrent.atomic.AtomicBoolean;

Expand All @@ -43,8 +39,7 @@ public BalFuture(Strand strand) {
@Override
public void complete(Object returnValue) {
if (visited.getAndSet(true)) {
throw ErrorCreator.createError(StringUtils.fromString("cannot complete the same future twice."),
new MapValueImpl<>(PredefinedTypes.TYPE_ERROR_DETAIL));
throw new IllegalStateException("cannot complete the same future twice.");
}
strand.returnValue = returnValue;
strand.scheduler.unblockStrand(strand);
Expand Down

0 comments on commit 320722f

Please sign in to comment.