{"record":{"id":"c7ed967739b1e116","repo":"apache/hadoop","slug":"setshufflefinishtime-not-supported-for-maptask","errorCode":null,"errorMessage":"setShuffleFinishTime() not supported for MapTask","messagePattern":"setShuffleFinishTime\\(\\) not supported for MapTask","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/MapTaskStatus.java","lineNumber":64,"sourceCode":"   * @param finishTime finish time of task.\n   */\n  @Override\n  void setFinishTime(long finishTime) {\n    super.setFinishTime(finishTime);\n    // set mapFinishTime if it hasn't been set before\n    if (getMapFinishTime() == 0) {\n      setMapFinishTime(finishTime);\n    }\n  }\n  \n  @Override\n  public long getShuffleFinishTime() {\n    throw new UnsupportedOperationException(\"getShuffleFinishTime() not supported for MapTask\");\n  }\n\n  @Override\n  void setShuffleFinishTime(long shuffleFinishTime) {\n    throw new UnsupportedOperationException(\"setShuffleFinishTime() not supported for MapTask\");\n  }\n\n  @Override\n  public long getMapFinishTime() {\n    return mapFinishTime;\n  }\n  \n  @Override\n  void setMapFinishTime(long mapFinishTime) {\n    this.mapFinishTime = mapFinishTime;\n  }\n  \n  @Override\n  synchronized void statusUpdate(TaskStatus status) {\n    super.statusUpdate(status);\n    \n    if (status.getMapFinishTime() != 0) {\n      this.mapFinishTime = status.getMapFinishTime();","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/MapTaskStatus.java#L46-L82","documentation":"MapTaskStatus rejects setShuffleFinishTime() with UnsupportedOperationException because a map task has no shuffle phase; only ReduceTaskStatus accepts shuffle timestamps (the framework sets them as the copy phase completes). Writing shuffle timing into a map status is an API misuse, and the guard makes it loud.","triggerScenarios":"Framework or tooling code copying timestamps across TaskStatus instances calls setShuffleFinishTime on a MapTaskStatus: history-replay tools applying every setter, custom AM code mirroring statuses between layers, unit tests constructing statuses generically.","commonSituations":"Job-history replay/audit utilities; custom ApplicationMaster status mirroring; shared helpers that hydrate TaskStatus fields from serialized maps.","solutions":["Guard with instanceof ReduceTaskStatus (or !status.getIsMap()) before calling shuffle setters","Apply only map-relevant fields (finishTime, mapFinishTime, state, progress) to MapTaskStatus","Centralize status copying in one adapter that knows both shapes instead of blanket setter loops"],"exampleFix":"// before\ncopy.setShuffleFinishTime(src.getShuffleFinishTime()); // throws when copy is a MapTaskStatus\n\n// after\nif (copy instanceof ReduceTaskStatus && src instanceof ReduceTaskStatus) {\n  ((ReduceTaskStatus) copy).setShuffleFinishTime(((ReduceTaskStatus) src).getShuffleFinishTime());\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean acceptsShuffleTimestamps(TaskStatus s) {\n  return s instanceof ReduceTaskStatus;\n}","tryCatchPattern":"if (acceptsShuffleTimestamps(copy)) { copy.setShuffleFinishTime(ts); } // guard before setter; a caught UnsupportedOperationException here means a type-handling bug, fix the caller","preventionTips":["Copy only map-relevant fields onto MapTaskStatus","Centralize status hydration in one adapter aware of both status shapes","Add reflection-friendly exclusions (transient/ignored getters) for serializers that walk all setters"],"tags":["hadoop","mapreduce","taskstatus","unsupported-operation","api-misuse"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}