{"record":{"id":"e25c439f48abbf2b","repo":"apache/flink","slug":"could-not-duplicate-simpleversionedserializer","errorCode":null,"errorMessage":"Could not duplicate SimpleVersionedSerializer.","messagePattern":"Could not duplicate SimpleVersionedSerializer\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/core/io/SimpleVersionedSerializerTypeSerializerProxy.java","lineNumber":63,"sourceCode":"\n    public SimpleVersionedSerializerTypeSerializerProxy(\n            SerializableSupplier<SimpleVersionedSerializer<T>> serializerSupplier) {\n        this.serializerSupplier = checkNotNull(serializerSupplier, \"serializerSupplier\");\n    }\n\n    @Override\n    public boolean isImmutableType() {\n        return false;\n    }\n\n    @Override\n    public TypeSerializer<T> duplicate() {\n        try {\n            return new SimpleVersionedSerializerTypeSerializerProxy<>(\n                    InstantiationUtil.clone(\n                            serializerSupplier, serializerSupplier.getClass().getClassLoader()));\n        } catch (ClassNotFoundException | IOException e) {\n            throw new RuntimeException(\"Could not duplicate SimpleVersionedSerializer.\", e);\n        }\n    }\n\n    @Override\n    public T createInstance() {\n        return null;\n    }\n\n    @Override\n    public T copy(T from) {\n        SimpleVersionedSerializer<T> serializer = getSerializer();\n        try {\n            byte[] serializedFrom = serializer.serialize(from);\n            return serializer.deserialize(serializer.getVersion(), serializedFrom);\n        } catch (IOException e) {\n            throw new RuntimeException(\"Could not copy element.\", e);\n        }\n    }","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/io/SimpleVersionedSerializerTypeSerializerProxy.java#L45-L81","documentation":"Thrown as a RuntimeException by SimpleVersionedSerializerTypeSerializerProxy.duplicate() when cloning the serializerSupplier via InstantiationUtil.clone fails with ClassNotFoundException or IOException. duplicate() deep-clones the SerializableSupplier so each duplicated TypeSerializer has an independent supplier; if the supplier's class or its dependencies are not on the classloader, or Java serialization of the supplier fails, this wrapping error is thrown.","triggerScenarios":"Calling TypeSerializer.duplicate() on a SimpleVersionedSerializerTypeSerializerProxy whose supplier is not Java-serializable or whose class is missing from the classloader; custom supplier classes referencing types not available at clone time.","commonSituations":"Classloader isolation issues (e.g. user-code classloader vs system classloader in a cluster); suppliers that capture non-Serializable lambdas or hold references to non-cloneable objects; deploying a job where the supplier's defining JAR is missing on some TaskManagers.","solutions":["Ensure the SerializableSupplier and all captured objects are Java-Serializable and available on the classloader performing duplicate().","If the supplier is a lambda, make sure it only captures Serializable-compatible state.","Verify the JAR containing the supplier class is deployed to all TaskManagers.","If duplicate() is not needed, consider whether the proxy is necessary at all."],"exampleFix":"// before — supplier captures non-serializable state\nSerializableSupplier<MySerializer> supplier = () -> new MySerializer(nonSerializableConfig);\n\n// after — supplier captures only serializable state\nSerializableSupplier<MySerializer> supplier = (SerializableSupplier<MySerializer>)\n    () -> new MySerializer(serializableConfig);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    TypeSerializer<T> dup = proxy.duplicate();\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof ClassNotFoundException) {\n        // ensure supplier class is on the classloader\n    }\n    throw e;\n}","preventionTips":["Ensure the SerializableSupplier and all captured objects are Java-Serializable.","Deploy the supplier's defining JAR to all cluster nodes.","Avoid capturing non-serializable or classloader-bound state in the supplier lambda."],"tags":["serialization","type-serializer","classloader","java-serialization"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}