{"record":{"id":"62e88de0c001199b","repo":"apache/flink","slug":"the-accumulator-object-name-was-created-with-t","errorCode":null,"errorMessage":"The accumulator object '{name}' was created with two different types: {first.getName()} and {second.getName()}","messagePattern":"The accumulator object '(.+?)' was created with two different types: (.+?) and (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/accumulators/AccumulatorHelper.java","lineNumber":104,"sourceCode":"        Accumulator<V, R> typedToMerge = (Accumulator<V, R>) toMerge;\n\n        typedTarget.merge(typedToMerge);\n\n        return typedTarget;\n    }\n\n    /** Compare both classes and throw {@link UnsupportedOperationException} if they differ. */\n    @SuppressWarnings(\"rawtypes\")\n    public static void compareAccumulatorTypes(\n            Object name, Class<? extends Accumulator> first, Class<? extends Accumulator> second)\n            throws UnsupportedOperationException {\n        if (first == null || second == null) {\n            throw new NullPointerException();\n        }\n\n        if (first != second) {\n            if (!first.getName().equals(second.getName())) {\n                throw new UnsupportedOperationException(\n                        \"The accumulator object '\"\n                                + name\n                                + \"' was created with two different types: \"\n                                + first.getName()\n                                + \" and \"\n                                + second.getName());\n            } else {\n                // damn, name is the same, but different classloaders\n                throw new UnsupportedOperationException(\n                        \"The accumulator object '\"\n                                + name\n                                + \"' was created with two different classes: \"\n                                + first\n                                + \" and \"\n                                + second\n                                + \" Both have the same type (\"\n                                + first.getName()\n                                + \") but different classloaders: \"","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/accumulators/AccumulatorHelper.java#L86-L122","documentation":"Thrown by AccumulatorHelper.compareAccumulatorTypes when two accumulators registered under the same name have different Java class names. Flink merges accumulator results from parallel subtasks by name; merging requires both to be the exact same accumulator type (e.g., both IntCounter). Different types cannot be merged, so the framework rejects the combination at result-collection time.","triggerScenarios":"Two operators/subtasks registering an accumulator under the same name but with different accumulator classes (e.g., one uses IntCounter, another LongCounter under name 'count'); copy-paste of accumulator names across operators that count different types.","commonSituations":"Reusing a generic accumulator name like 'count' or 'sum' in unrelated UDFs; library code that registers accumulators with fixed names that collide with user code.","solutions":["Give every accumulator a unique name, or ensure all subtasks that share a name use the identical accumulator class.","Namespace accumulator names per operator (e.g., 'opA.count', 'opB.count').","Audit getRuntimeContext().getXxxCounter(...) calls for name collisions across the job."],"exampleFix":"// before\ngetRuntimeContext().getIntCounter(\"count\");  // operator A\ngetRuntimeContext().getLongCounter(\"count\");  // operator B -> mismatch\n// after\ngetRuntimeContext().getIntCounter(\"opA.count\");\ngetRuntimeContext().getLongCounter(\"opB.count\");","handlingStrategy":"validation","validationCode":"// use distinct names per accumulator type\ngetRuntimeContext().getIntCounter(\"opA.count\");\ngetRuntimeContext().getLongCounter(\"opB.count\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give each accumulator a unique, namespaced name.","Ensure all subtasks sharing a name use the same accumulator class.","Audit accumulator names during code review."],"tags":["accumulator","type-mismatch","merge","naming"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}