{"record":{"id":"9fd1fa3e49d9ee8c","repo":"apache/flink","slug":"operator-producing-the-next-partial-solution-must","errorCode":null,"errorMessage":"Operator producing the next partial solution must not be null.","messagePattern":"Operator producing the next partial solution must not be null\\.","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/operators/base/BulkIterationBase.java","lineNumber":102,"sourceCode":"                name);\n        inputPlaceHolder = new PartialSolutionPlaceHolder<T>(this, this.getOperatorInfo());\n    }\n\n    // --------------------------------------------------------------------------------------------\n\n    /**\n     * @return The operator representing the partial solution.\n     */\n    public Operator<T> getPartialSolution() {\n        return this.inputPlaceHolder;\n    }\n\n    /**\n     * @param result\n     */\n    public void setNextPartialSolution(Operator<T> result) {\n        if (result == null) {\n            throw new NullPointerException(\n                    \"Operator producing the next partial solution must not be null.\");\n        }\n        this.iterationResult = result;\n    }\n\n    /**\n     * @return The operator representing the next partial solution.\n     */\n    public Operator<T> getNextPartialSolution() {\n        return this.iterationResult;\n    }\n\n    /**\n     * @return The operator representing the termination criterion.\n     */\n    public Operator<?> getTerminationCriterion() {\n        return this.terminationCriterion;\n    }","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/operators/base/BulkIterationBase.java#L84-L120","documentation":"Thrown by BulkIterationBase.setNextPartialSolution(Operator<T> result) with a NullPointerException when the result argument is null. The 'next partial solution' is the operator that produces the updated solution for each iteration step — it is the core of the iteration body and cannot be absent.","triggerScenarios":"Calling iteration.setNextPartialSolution(null) directly. Passing a variable that was not initialized or was conditionally set to null as the step function result.","commonSituations":"Building a bulk iteration programmatically (legacy DataSet API) where the step function is computed from conditional logic that may return null. Refactoring code where the step function operator was removed but the call site was not updated.","solutions":["Ensure the step function operator (the body of the iteration that produces the next partial solution) is always non-null before calling setNextPartialSolution().","Initialize the step function variable before the call, or assert it is not null.","Use the DeltaIteration API if you need a different iteration model."],"exampleFix":"// before\nOperator<MyType> stepFunction = buildStepFunction(iteration.getPartialSolution());\n// buildStepFunction may return null\niteration.setNextPartialSolution(stepFunction); // NPE if null\n\n// after\nOperator<MyType> stepFunction = buildStepFunction(iteration.getPartialSolution());\njava.util.Objects.requireNonNull(stepFunction, \"step function must not be null\");\niteration.setNextPartialSolution(stepFunction);","handlingStrategy":"validation","validationCode":"void safeSetNextPartialSolution(BulkIterationBase<T> iter, Operator<T> result) {\n    java.util.Objects.requireNonNull(result, \"Step function operator must not be null\");\n    iter.setNextPartialSolution(result);\n}","typeGuard":"boolean isValidStepFunction(Operator<?> result) {\n    return result != null;\n}","tryCatchPattern":"try {\n    iteration.setNextPartialSolution(stepFunction);\n} catch (NullPointerException e) {\n    throw new IllegalStateException(\"Iteration step function was null\", e);\n}","preventionTips":["Use Objects.requireNonNull(stepFunction, msg) before calling setNextPartialSolution.","Initialize step function variables to non-null defaults.","Build the step function inline from iteration.getPartialSolution() to ensure it is always connected."],"tags":["bulk-iteration","null-check","dataset-api","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}