Skip to content

Commit

Permalink
Merge pull request #43696 from ravinperera00/issue_43654
Browse files Browse the repository at this point in the history
[2201.7.x] - Use Java exception to notify `cannot complete future twice`
  • Loading branch information
warunalakshitha authored Dec 11, 2024
2 parents 9701a1d + 9cd1a12 commit 851bc69
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 @@ -42,8 +38,7 @@ public BalFuture(Strand strand) {

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 851bc69

Please sign in to comment.