Merge CB-577 follow-up: drop the target-keyed async index
CI / contract (push) Successful in 43s
CI / build (push) Successful in 55s

asyncTasksByWaiter correlates an async question by the exact rendezvous
waiter, so the target-keyed set it replaced can no longer decide
anything. Keeping it meant two indexes of the same fact, one of them
ambiguous whenever a target has two accepted tickets.

The race the old test modelled by reflection is gone with it: identity
keys make 'some other task reached this target' unrepresentable, so
there is no longer a wrong task for the question to land on.

Also carries the criterion-1 doc correction, which is identical to
aac29d6 on a different parent.
This commit is contained in:
Dai Ha
2026-08-15 06:40:31 +02:00
2 changed files with 1 additions and 39 deletions
@@ -10,9 +10,6 @@ import dev.ltms.bridged.inject.Injector;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
@@ -697,22 +694,10 @@ class MessageServiceTest {
}
@Test
@SuppressWarnings("unchecked")
void asyncQuestionBelongsToTheTaskThatOwnsItsForwardWaiter() throws Exception {
String first = messages.sendAsync(T, "first task");
awaitWaiting();
// Model the resolveQuestion/markAsyncQuestion race: another accepted task reached the target set.
Field byTargetField = MessageService.class.getDeclaredField("asyncTasksByTarget");
byTargetField.setAccessible(true);
Map<String, Set<Object>> byTarget = (Map<String, Set<Object>>) byTargetField.get(messages);
Set<Object> targetTasks = byTarget.get(T);
Class<?> taskClass = Class.forName(MessageService.class.getName() + "$Task");
var constructor = taskClass.getDeclaredConstructor(String.class);
constructor.setAccessible(true);
targetTasks.clear();
targetTasks.add(constructor.newInstance(T));
CompletableFuture<MessageService.AskResult> ask =
CompletableFuture.supplyAsync(() -> messages.ask(T, "which config?", 5000));
assertEquals(MessageService.Phase.ASKING, awaitTicketPhase(first, MessageService.Phase.ASKING).phase());