{"record":{"id":"821c7ebd097b77d1","repo":"apache/flink","slug":"jobconf-may-not-be-null","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/HadoopMapFunction.java","lineNumber":80,"sourceCode":"     * @param hadoopMapper The Hadoop Mapper to wrap.\n     */\n    public HadoopMapFunction(Mapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT> hadoopMapper) {\n        this(hadoopMapper, new JobConf());\n    }\n\n    /**\n     * Maps a Hadoop Mapper (mapred API) to a Flink FlatMapFunction. The Hadoop Mapper is configured\n     * with the provided JobConf.\n     *\n     * @param hadoopMapper The Hadoop Mapper to wrap.\n     * @param conf The JobConf that is used to configure the Hadoop Mapper.\n     */\n    public HadoopMapFunction(Mapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT> hadoopMapper, JobConf conf) {\n        if (hadoopMapper == null) {\n            throw new NullPointerException(\"Mapper may not be null.\");\n        }\n        if (conf == null) {\n            throw new NullPointerException(\"JobConf may not be null.\");\n        }\n\n        this.mapper = hadoopMapper;\n        this.jobConf = conf;\n    }\n\n    @PublicEvolving\n    @Override\n    public void open(OpenContext openContext) throws Exception {\n        super.open(openContext);\n        this.mapper.configure(jobConf);\n\n        this.reporter = new HadoopDummyReporter();\n        this.outputCollector = new HadoopOutputCollector<KEYOUT, VALUEOUT>();\n    }\n\n    @Override\n    public void flatMap(","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/hadoopcompatibility/mapred/HadoopMapFunction.java#L62-L98","documentation":"Thrown by the HadoopMapFunction(Mapper, JobConf) constructor when the JobConf argument is null. JobConf is required to configure the Mapper in open(); a null conf cannot be serialized or used, so construction fails fast with a NullPointerException. Note the single-arg constructor supplies a fresh JobConf() to avoid this.","triggerScenarios":"Produced when new HadoopMapFunction(hadoopMapper, conf) is called with conf == null — e.g. a JobConf reference that was never created, a configuration source returning null, or test code passing null for the conf parameter.","commonSituations":"A JobConf built conditionally and left null when the condition is false; a config loader returning null; copy-paste passing a null conf; tests that omit the JobConf argument. The single-arg constructor (mapper only) avoids this by defaulting to new JobConf().","solutions":["Pass a non-null JobConf (or use the single-arg HadoopMapFunction(mapper) constructor, which defaults to new JobConf()).","If the JobConf comes from a loader, ensure it never returns null (fail loud or supply an empty JobConf).","In tests, construct a real JobConf rather than passing null.","Add a null-check at the call site before constructing the wrapper."],"exampleFix":"// before\nJobConf conf = confLoader.load(); // may be null\nnew HadoopMapFunction(mapper, conf);\n// after — ensure non-null conf, or use the default\nJobConf conf = confLoader.load();\nnew HadoopMapFunction(mapper, conf != null ? conf : new JobConf());","handlingStrategy":"validation","validationCode":"java.util.Objects.requireNonNull(conf, \"JobConf must not be null\");\nnew HadoopMapFunction(hadoopMapper, conf);\n// or simply use the single-arg constructor that defaults to new JobConf():\nnew HadoopMapFunction(hadoopMapper);","typeGuard":"conf != null","tryCatchPattern":null,"preventionTips":["Pass a non-null JobConf, or use the HadoopMapFunction(mapper) constructor.","Ensure config loaders never return null (default to new JobConf()).","In tests, construct a real JobConf.","Guard the conf reference with Objects.requireNonNull before constructing."],"tags":["hadoop","mapred","validation","constructor","jobconf"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}