{"record":{"id":"f182a025e60ed09a","repo":"apache/hadoop","slug":"job-priority-cannot-be-null","errorCode":null,"errorMessage":"Job Priority cannot be null.","messagePattern":"Job Priority cannot be null\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobStatus.java","lineNumber":211,"sourceCode":"  * @param isUber Whether job running in uber mode\n  * @param historyFile history file\n  */\n  public JobStatus(JobID jobid, float setupProgress, float mapProgress,\n                   float reduceProgress, float cleanupProgress,\n                   State runState, JobPriority jp,\n                   String user, String jobName, String queue,\n                   String jobFile, String trackingUrl, boolean isUber,\n                   String historyFile) {\n    this.jobid = jobid;\n    this.setupProgress = setupProgress;\n    this.mapProgress = mapProgress;\n    this.reduceProgress = reduceProgress;\n    this.cleanupProgress = cleanupProgress;\n    this.runState = runState;\n    this.user = user;\n    this.queue = queue;\n    if (jp == null) {\n      throw new IllegalArgumentException(\"Job Priority cannot be null.\");\n    }\n    priority = jp;\n    this.jobName = jobName;\n    this.jobFile = jobFile;\n    this.trackingUrl = trackingUrl;\n    this.isUber = isUber;\n    this.historyFile = historyFile;\n  }\n\n\n  /**\n   * Sets the map progress of this job\n   * @param p The value of map progress to set to\n   */\n  protected synchronized void setMapProgress(float p) { \n    this.mapProgress = (float) Math.min(1.0, Math.max(0.0, p)); \n  }\n","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobStatus.java#L193-L229","documentation":"org.apache.hadoop.mapreduce.JobStatus is the wire/DAO object describing a job. Its primary constructor requires a non-null JobPriority (jp) — null means corrupted or missing data, since every real JobTracker/RM assigns at least NORMAL — so it throws IllegalArgumentException('Job Priority cannot be null.') at JobStatus.java:211 rather than silently building an inconsistent status.","triggerScenarios":"Application code constructing JobStatus directly (mocks, test fixtures, custom monitoring layers) and passing null for priority; deserialization/RPC paths from a peer that omitted the priority field; old Hadoop 1.x-era data being read into the 2.x/3.x class where the field ordering or presence differs.","commonSituations":"Unit tests stubbing JobStatus with a compact constructor call; homegrown tooling that synthesizes JobStatus objects from parsed logs; version-mismatched client/server jars on the classpath causing partial deserialization.","solutions":["Pass an explicit default: JobPriority.NORMAL when priority is unknown","In tests, use a builder or helper that always fills priority instead of hand-writing constructor args","Align client and cluster Hadoop versions so RPC deserialization populates all fields","Null-check upstream data and substitute NORMAL before constructing, logging the substitution"],"exampleFix":"// before\nJobStatus st = new JobStatus(id, 0f, 0f, 0f, 0f, State.RUNNING,\n    JobStatus.Syntax.OLD, \"user\", \"job\", \"default\", \"file\", \"url\", false, null, null);\n// -> IllegalArgumentException: Job Priority cannot be null.\n\n// after\nJobPriority prio = (parsedPriority != null) ? parsedPriority : JobPriority.NORMAL;\nJobStatus st = new JobStatus(id, 0f, 0f, 0f, 0f, State.RUNNING,\n    JobStatus.Syntax.OLD, \"user\", \"job\", \"default\", \"file\", \"url\", false, prio, null);","handlingStrategy":"validation","validationCode":"// normalize priority before constructing JobStatus\nJobPriority effective = (priority != null) ? priority : JobPriority.NORMAL;\nJobStatus st = new JobStatus(jobid, 0f, 0f, 0f, 0f, runState,\n    syncInfo, user, jobName, queue, jobFile, trackingUrl, isUber, effective, historyFile);","typeGuard":"static JobPriority nonNullPriority(JobPriority p) {\n  return (p != null) ? p : JobPriority.NORMAL;\n}","tryCatchPattern":"try {\n  return new JobStatus(..., jp, ...);\n} catch (IllegalArgumentException e) {\n  if (\"Job Priority cannot be null.\".equals(e.getMessage())) {\n    return new JobStatus(..., JobPriority.NORMAL, ...); // or fix upstream data\n  }\n  throw e;\n}","preventionTips":["Default missing priorities to JobPriority.NORMAL at the data boundary","In tests, use helpers/builders that fill every required field","Keep client and cluster Hadoop versions aligned so RPC fields are never missing"],"tags":["job-status","null-check","constructor","argument-validation","mapreduce"],"backgroundTag":"null-argument-validation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}