{"record":{"id":"a759280dc608ccf0","repo":"apache/flink","slug":"jobconf-may-not-be-null-a75928","errorCode":null,"errorMessage":"JobConf may not be null.","messagePattern":"JobConf may not be null\\.","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/mapred/HadoopReducerWrappedFunction.java","lineNumber":93,"sourceCode":"     * @param hadoopReducer The Hadoop Reducer to wrap.\n     */\n    public HadoopReducerWrappedFunction(Reducer<KEYIN, VALUEIN, KEYOUT, VALUEOUT> hadoopReducer) {\n        this(hadoopReducer, new JobConf());\n    }\n\n    /**\n     * Maps a Hadoop Reducer (mapred API) to a non-combinable Flink GroupReduceFunction.\n     *\n     * @param hadoopReducer The Hadoop Reducer to wrap.\n     * @param conf The JobConf that is used to configure the Hadoop Reducer.\n     */\n    public HadoopReducerWrappedFunction(\n            Reducer<KEYIN, VALUEIN, KEYOUT, VALUEOUT> hadoopReducer, JobConf conf) {\n        if (hadoopReducer == null) {\n            throw new NullPointerException(\"Reducer may not be null.\");\n        }\n        if (conf == null) {\n            throw new NullPointerException(\"JobConf may not be null.\");\n        }\n\n        this.reducer = hadoopReducer;\n        this.jobConf = conf;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @PublicEvolving\n    @Override\n    public void open(OpenContext openContext) throws Exception {\n        super.open(openContext);\n        this.reducer.configure(jobConf);\n\n        this.reporter = new HadoopDummyReporter();\n        this.reduceCollector = new HadoopOutputCollector<KEYOUT, VALUEOUT>();\n        Class<KEYIN> inKeyClass =\n                (Class<KEYIN>) TypeExtractor.getParameterType(Reducer.class, reducer.getClass(), 0);\n        TypeSerializer<KEYIN> keySerializer =","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/mapred/HadoopReducerWrappedFunction.java#L75-L111","documentation":"Thrown by the HadoopReducerWrappedFunction two-arg constructor when the JobConf argument is null. The JobConf is stored and later passed to reducer.configure(jobConf) in open(); a null conf would NPE inside the Hadoop Reducer lifecycle. The one-arg constructor avoids this by supplying a default new JobConf(), so this only fires when you explicitly pass null to the two-arg overload.","triggerScenarios":"Calling new HadoopReducerWrappedFunction(reducer, null) directly, or a builder/factory that forwards a conf variable that was never initialized.","commonSituations":"Sharing a JobConf across operators where one branch left it null; refactoring that introduced a code path bypassing the default JobConf creation; tests constructing the wrapper manually without a conf.","solutions":["Pass a valid JobConf (new JobConf() is acceptable if you have no Hadoop config to carry over).","Prefer the one-arg constructor HadoopReducerWrappedFunction(reducer) which internally supplies a fresh JobConf.","Guard the caller: if (conf == null) conf = new JobConf(); before constructing the wrapper."],"exampleFix":"// before\nnew HadoopReducerWrappedFunction<>(reducer, null);\n// after\nJobConf conf = (conf == null) ? new JobConf() : conf;\nnew HadoopReducerWrappedFunction<>(reducer, conf);","handlingStrategy":"validation","validationCode":"JobConf safe = (conf != null) ? conf : new JobConf();\nnew HadoopReducerWrappedFunction<>(reducer, safe);","typeGuard":"// guard the conf before constructing\nif (conf == null) conf = new JobConf();","tryCatchPattern":null,"preventionTips":["Prefer the one-arg constructor that supplies a default JobConf.","Centralize JobConf creation so a single non-null instance is shared.","Treat null config as a bug at the source, not at the wrapper boundary."],"tags":["hadoop-compatibility","mapred","null-check","constructor"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}