apache/flink · error · IllegalArgumentException

Unknown class resolution order: {resolveOrder}

Error message

Unknown class resolution order: {resolveOrder}

What it means

FlinkUserCodeClassLoaders.getClassLoader(...) switch-cases the ResolveOrder enum: CHILD_FIRST and PARENT_FIRST each build a loader; any other value hits the default branch and throws IllegalArgumentException("Unknown class resolution order: " + resolveOrder). Because the enum only has two constants, this is only reachable if someone passes a null or a cast/modified enum value programmatically — config strings normally arrive via ResolveOrder.fromString.

Source

Thrown at flink-core/src/main/java/org/apache/flink/util/FlinkUserCodeClassLoaders.java:100

            URL[] urls,
            ClassLoader parent,
            String[] alwaysParentFirstPatterns,
            Consumer<Throwable> classLoadingExceptionHandler,
            boolean checkClassLoaderLeak) {

        switch (resolveOrder) {
            case CHILD_FIRST:
                return childFirst(
                        urls,
                        parent,
                        alwaysParentFirstPatterns,
                        classLoadingExceptionHandler,
                        checkClassLoaderLeak);
            case PARENT_FIRST:
                return parentFirst(
                        urls, parent, classLoadingExceptionHandler, checkClassLoaderLeak);
            default:
                throw new IllegalArgumentException(
                        "Unknown class resolution order: " + resolveOrder);
        }
    }

    private static MutableURLClassLoader wrapWithSafetyNet(
            FlinkUserCodeClassLoader classLoader, boolean check) {
        return check
                ? new SafetyNetWrapperClassLoader(classLoader, classLoader.getParent())
                : classLoader;
    }

    /** Class resolution order for Flink URL {@link ClassLoader}. */
    public enum ResolveOrder {
        CHILD_FIRST,
        PARENT_FIRST;

        public static ResolveOrder fromString(String resolveOrder) {
            if (resolveOrder.equalsIgnoreCase("parent-first")) {

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Pass a value obtained from ResolveOrder.fromString(...) so config strings map to a valid constant
  2. If you forked Flink and added a ResolveOrder constant, add a matching case to this switch
  3. Null-check the resolve order before calling and default it to the documented value (child-first)

Example fix

// before
FlinkUserCodeClassLoaders.getUrlClassLoader(urls, parent, null, handler, false); // null order

// after
ResolveOrder order = ResolveOrder.fromString(
        conf.get(CoreOptions.CLASSLOADER_RESOLVE_ORDER)); // 'child-first'/'parent-first'
Defensive patterns

Strategy: validation

Validate before calling

ResolveOrder order = ResolveOrder.fromString(conf.get(CoreOptions.CLASSLOADER_RESOLVE_ORDER));

Prevention

When it happens

Trigger: Programmatically calling FlinkUserCodeClassLoaders.getClassLoader / childFirst / parentFirst factory paths with a null ResolveOrder or an enum constant added by a fork/patch; reflective invocation passing the wrong type.

Common situations: Custom Flink forks adding a new resolve order without extending the switch; passing an unresolved config value straight into the API instead of using ResolveOrder.fromString(CoreOptions.CLASSLOADER_RESOLVE_ORDER).

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/95eea3f24361bf03. Report an issue: GitHub.