{"record":{"id":"8d48f9e40ecf9bb4","repo":"apache/flink","slug":"this-jobsubmissionresult-is-not-a-jobexecutionresu","errorCode":null,"errorMessage":"This JobSubmissionResult is not a JobExecutionResult.","messagePattern":"This JobSubmissionResult is not a JobExecutionResult\\.","errorType":"exception","errorClass":"ClassCastException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/JobSubmissionResult.java","lineNumber":60,"sourceCode":"\n    /**\n     * Checks if this JobSubmissionResult is also a JobExecutionResult. See {@code\n     * getJobExecutionResult} to retrieve the JobExecutionResult.\n     *\n     * @return True if this is a JobExecutionResult, false otherwise\n     */\n    public boolean isJobExecutionResult() {\n        return false;\n    }\n\n    /**\n     * Returns the JobExecutionResult if available.\n     *\n     * @return The JobExecutionResult\n     * @throws ClassCastException if this is not a JobExecutionResult\n     */\n    public JobExecutionResult getJobExecutionResult() {\n        throw new ClassCastException(\"This JobSubmissionResult is not a JobExecutionResult.\");\n    }\n}\n","sourceCodeStart":42,"sourceCodeEnd":63,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/JobSubmissionResult.java#L42-L63","documentation":"Thrown by JobSubmissionResult.getJobExecutionResult() on the base class, which never holds an execution result. JobSubmissionResult represents a submitted job; only its subclass JobExecutionResult (returned by execute() on a local/mini-cluster environment) carries runtime accumulators and timing. Calling this on a plain JobSubmissionResult (e.g., from detached submission) is a type mismatch the API refuses statically by always throwing ClassCastException.","triggerScenarios":"Calling result.getJobExecutionResult() without first checking isJobExecutionResult(); storing a JobSubmissionResult reference and downcasting blindly; using execute() vs executeAsync()/detach mode interchangeably.","commonSituations":"Detached submission (env.executeAsync / detached mode) returns a bare JobSubmissionResult; reusing code that expected the synchronous execute() return type; refactoring from blocking to async submission.","solutions":["Call isJobExecutionResult() first and only call getJobExecutionResult() when it returns true.","Use the concrete return type: if you submitted via execute() synchronously, the declared return is already JobExecutionResult.","For detached/async jobs, fetch results later via the RestClusterClient/JobClient instead of the submission result."],"exampleFix":"// before\nJobExecutionResult r = result.getJobExecutionResult();\n// after\nif (result.isJobExecutionResult()) {\n    JobExecutionResult r = result.getJobExecutionResult();\n    // use r.getJobExecutionTime(), accumulators, etc.\n} else {\n    // detached/async: poll via JobClient instead\n}","handlingStrategy":"type-guard","validationCode":"if (result.isJobExecutionResult()) {\n    JobExecutionResult r = result.getJobExecutionResult();\n}","typeGuard":"public static Optional<JobExecutionResult> asExecutionResult(JobSubmissionResult r) {\n    return r != null && r.isJobExecutionResult()\n        ? Optional.of(r.getJobExecutionResult())\n        : Optional.empty();\n}","tryCatchPattern":null,"preventionTips":["Always gate getJobExecutionResult() behind isJobExecutionResult().","Use JobClient/RestClusterClient for async/detached job results.","Type the variable as JobExecutionResult when you call execute() synchronously."],"tags":["job-result","type-mismatch","execution","classcast"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}