alibaba/ARouter · error · IllegalArgumentException

Interceptor initialization failure must have a cause.

Error message

Interceptor initialization failure must have a cause.

What it means

InterceptorInitState.fail() records a failed interceptor initialization and wakes waiters, but a null cause would leave waiters with no reason for the failure. It therefore throws IllegalArgumentException when fail() is called without a Throwable cause.

Source

Thrown at arouter-api/src/main/java/com/alibaba/android/arouter/core/InterceptorInitState.java:63

    void start() {
        synchronized (lock) {
            status = Status.INITIALIZING;
            failure = null;
            lock.notifyAll();
        }
    }

    void succeed() {
        synchronized (lock) {
            status = Status.SUCCEEDED;
            failure = null;
            lock.notifyAll();
        }
    }

    void fail(Throwable cause) {
        if (cause == null) {
            throw new IllegalArgumentException("Interceptor initialization failure must have a cause.");
        }

        synchronized (lock) {
            status = Status.FAILED;
            failure = cause;
            lock.notifyAll();
        }
    }

    Result await(long timeout, TimeUnit unit) throws InterruptedException {
        if (unit == null) {
            throw new NullPointerException("TimeUnit must not be null.");
        }

        long timeoutNanos = unit.toNanos(timeout);
        long startNanos = System.nanoTime();

        synchronized (lock) {

View on GitHub (pinned to 84f451d244)

Solutions

  1. Always pass the caught exception to fail(), even if wrapped in a new exception
  2. If no real exception exists, create one: fail(new IllegalStateException("init failed for reason X"))
  3. Audit init code paths that call fail() to ensure the catch variable is not discarded

Example fix

// before
try { interceptor.init(ctx); initState.success(); }
catch (Exception e) { initState.fail(null); }
// after
try { interceptor.init(ctx); initState.success(); }
catch (Exception e) { initState.fail(e); }
Defensive patterns

Strategy: validation

Validate before calling

if (cause == null) {
    cause = new IllegalStateException("interceptor init failed (no cause captured)");
}
initState.fail(cause);

Try / catch

try {
    interceptor.init(ctx);
} catch (Throwable t) {
    initState.fail(t != null ? t : new IllegalStateException("init failed"));
}

Prevention

When it happens

Trigger: Calling InterceptorInitState.fail(null), typically from a catch block that lost the throwable or from a caller that reports failure without an exception.

Common situations: Custom interceptor init wrappers that construct failure state manually; refactored catch blocks where the original exception variable was dropped.

Related errors


AI-assisted analysis of alibaba/ARouter@84f451d244 (2026-09-06). Data as JSON: /api/errors/b0e18f783024af4b. Report an issue: GitHub.