junit-team/junit5 · critical · IllegalStateException
Could not add entry to the queue for task: ${entry.task}
Error message
Could not add entry to the queue for task: ${entry.task} What it means
Thrown by WorkQueue.doAdd (line 690-695) as an IllegalStateException when ConcurrentSkipListSet.add(entry) returns false, i.e. an Entry equal to one already in the queue was added again. Entry equality (line 761-770) is based on (uniqueId, index), so a duplicate add implies the same UniqueId at the same child index was enqueued twice. This is an internal invariant of the WorkerThreadPool executor and signals a logic bug rather than a user config issue.
Source
Thrown at junit-platform-engine/src/main/java/org/junit/platform/engine/support/hierarchical/WorkerThreadPoolHierarchicalTestExecutorService.java:693
Entry add(TestTask task, int index) {
Entry entry = new Entry(task, index);
logger.trace(() -> "forking: " + entry.task);
return doAdd(entry);
}
void addAll(Collection<Entry> entries) {
entries.forEach(this::doAdd);
}
void reAdd(Entry entry) {
logger.trace(() -> "re-enqueuing: " + entry.task);
doAdd(entry);
}
private Entry doAdd(Entry entry) {
var added = queue.add(entry);
if (!added) {
throw new IllegalStateException("Could not add entry to the queue for task: " + entry.task);
}
return entry;
}
boolean remove(Entry entry) {
return queue.remove(entry);
}
boolean isEmpty() {
return queue.isEmpty();
}
@Override
public Iterator<Entry> iterator() {
return queue.iterator();
}
private static final class Entry {View on GitHub (pinned to 956246301e)
Solutions
- File a JUnit issue with the full stack trace; this is an executor-internal invariant violation, not a configuration error.
- As a workaround, disable parallel execution (junit.jupiter.execution.parallel.enabled=false) to avoid the WorkerThreadPool code path.
- Audit any custom SelectorResolver / Node.Task that might produce non-unique UniqueIds or recursive submissions.
- Upgrade to the latest JUnit Platform release; duplicate-enqueue bugs are typically fixed promptly.
Defensive patterns
Strategy: try-catch
Try / catch
try {
executorService.submit(testTask);
} catch (IllegalStateException e) {
if (e.getMessage().contains("Could not add entry to the queue")) {
// internal invariant violation; collect diagnostics and report upstream
log.error("JUnit executor invariant violation", e);
}
throw e;
} Prevention
- Keep JUnit Platform on the latest patch release; internal executor bugs get fixed there.
- Audit custom Node.Task/SelectorResolver for non-unique UniqueIds or recursive submissions.
- Disable parallel execution as a workaround if the bug blocks CI.
When it happens
Trigger: The executor's bookkeeping re-enqueues an Entry whose (uniqueId, index) pair is already pending (e.g. a reAdd() on an entry still in the queue, or a forkAll path that double-counts a child). Reached during parallel test execution with WorkerThreadPoolHierarchicalTestExecutorService (default parallel executor since 6.1).
Common situations: An engine bug or a pathological test hierarchy producing duplicate UniqueIds at the same nesting index under concurrent execution; custom Node.Task implementations that re-submit themselves; races when two code paths enqueue the same descriptor.
Related errors
- Not on a worker thread
- Task was deferred but should have been executed synchronousl
- Failed to create ForkJoinPool
- Selector ${selector} did not yield unique test descriptor: $
- 'ResourceLockTarget.CHILDREN' is not supported for methods.
AI-assisted analysis of junit-team/junit5@956246301e (2026-08-04).
Data as JSON: /data/errors/e3699c8d5d66bfcc.json.
Report an issue: GitHub.