Netflix/Hystrix · error · RuntimeException

Couldn't invoke ThreadManager.currentRequestThreadFactory

Error message

Couldn't invoke ThreadManager.currentRequestThreadFactory

What it means

PlatformSpecific.getAppEngineThreadFactory reflectively loads com.google.appengine.api.ThreadManager and invokes currentRequestThreadFactory() to build threads on Google App Engine. An IllegalAccessException from the reflection call - the method or class is not accessible under the current security/classloader rules - is rethrown as this RuntimeException.

Source

Thrown at hystrix-core/src/main/java/com/netflix/hystrix/util/PlatformSpecific.java:82

        } catch (InvocationTargetException e) {
            // If ApiProxy throws an exception, we're not in a proper AppEngine environment.
            return Platform.STANDARD;
        } catch (IllegalAccessException e) {
            // If the method isn't accessible, we're not on a supported version of AppEngine;
            return Platform.STANDARD;
        } catch (NoSuchMethodException e) {
            // If the method doesn't exist, we're not on a supported version of AppEngine;
            return Platform.STANDARD;
        }
    }

    public static ThreadFactory getAppEngineThreadFactory() {
        try {
            return (ThreadFactory) Class.forName("com.google.appengine.api.ThreadManager")
                    .getMethod("currentRequestThreadFactory")
                    .invoke(null);
        } catch (IllegalAccessException e) {
            throw new RuntimeException("Couldn't invoke ThreadManager.currentRequestThreadFactory", e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException("Couldn't invoke ThreadManager.currentRequestThreadFactory", e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException("Couldn't invoke ThreadManager.currentRequestThreadFactory", e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e.getCause());
        }
    }
}

View on GitHub (pinned to 5ce3bc58c3)

Solutions

  1. If not actually on AppEngine, remove or scope the com.google.appengine dependency so PlatformSpecific.isAppEngine() returns false.
  2. On AppEngine, ensure the runtime's ThreadManager API is accessible (do not override the security policy that blocks it).
  3. Avoid calling getAppEngineThreadFactory() directly; let Hystrix pick the platform automatically.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    ThreadFactory f = PlatformSpecific.getAppEngineThreadFactory();
} catch (RuntimeException e) {
    ThreadFactory f = Executors.defaultThreadFactory(); // fall back off AppEngine
}

Prevention

When it happens

Trigger: Running with isAppEngine() detection returning true (AppEngine classes present) while the security manager or classloader blocks reflective access to ThreadManager.currentRequestThreadFactory(); partially loaded AppEngine API jars on a non-AppEngine runtime.

Common situations: AppEngine API jar on the classpath of a regular servlet container, confusing platform detection; restrictive SecurityManager policies denying reflective access; running Hystrix unit tests with an AppEngine SDK stub.

Related errors


AI-assisted analysis of Netflix/Hystrix@5ce3bc58c3 (2026-08-14). Data as JSON: /api/errors/f1af8e95825c064a. Report an issue: GitHub.