apache/cassandra · error · IllegalArgumentException

threadGroup may only be overridden with a child of the defau

Error message

threadGroup may only be overridden with a child of the default threadGroup

What it means

Thrown by ThreadPoolExecutorBuilder.withThreadGroup when the supplied ThreadGroup is not the current default threadGroup itself nor a child (direct or nested) of it. Cassandra only permits narrowing the thread group within its default group to keep pool threads manageable.

Source

Thrown at src/java/org/apache/cassandra/concurrent/ThreadPoolExecutorBuilder.java:118

        return this;
    }

    public ThreadPoolExecutorBuilder<E> withThreadPriority(int threadPriority)
    {
        this.threadPriority = threadPriority;
        return this;
    }

    @Override
    public ExecutorBuilder<E> withThreadGroup(ThreadGroup threadGroup)
    {
        ThreadGroup current = this.threadGroup;

        ThreadGroup parent = threadGroup;
        while (parent != null && parent != current)
            parent = parent.getParent();
        if (parent != current)
            throw new IllegalArgumentException("threadGroup may only be overridden with a child of the default threadGroup");

        this.threadGroup = threadGroup;
        return this;
    }

    @Override
    public ExecutorBuilder<E> withDefaultThreadGroup()
    {
        this.threadGroup = null;
        return this;
    }

    public ThreadPoolExecutorBuilder<E> withQueueLimit(int queueLimit)
    {
        this.queueLimit = queueLimit;
        return this;
    }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Pass a ThreadGroup that is a child of the default thread group (create it with new ThreadGroup(defaultGroup, name))
  2. Omit withThreadGroup() entirely to inherit the default
  3. If a fully separate group is required, attach it to the default group first via setParent-like construction or restructure the threading model

Example fix

// before
builder.withThreadGroup(new ThreadGroup("my-pool"));
// after
builder.withThreadGroup(new ThreadGroup(Thread.currentThread().getThreadGroup(), "my-pool"));
Defensive patterns

Strategy: validation

Validate before calling

ThreadGroup current = Thread.currentThread().getThreadGroup();
ThreadGroup parent = candidate;
while (parent != null && parent != current) parent = parent.getParent();
boolean allowed = (parent == current);

Prevention

When it happens

Trigger: Calling withThreadGroup() on a builder with a ThreadGroup created outside the default group's hierarchy, e.g. a fresh new ThreadGroup("...") with no parent linkage to the default group.

Common situations: Embedding Cassandra or its wrappers in application servers that use custom root ThreadGroups, refactoring pool creation code and constructing a standalone ThreadGroup.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/23b3fe250d89a455. Report an issue: GitHub.