{"record":{"id":"943118c175be43a8","repo":"apache/hadoop","slug":"cannot-specify-the-same-xattr-to-be-set-more-than","errorCode":null,"errorMessage":"Cannot specify the same XAttr to be set more than once","messagePattern":"Cannot specify the same XAttr to be set more than once","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java","lineNumber":330,"sourceCode":"        throw new IOException(\"Can only set '\" +\n            XATTR_SNAPSHOT_DELETED + \"' on a snapshot root.\");\n      }\n    }\n\n    XAttrStorage.updateINodeXAttrs(inode, newXAttrs, iip.getLatestSnapshotId());\n    return inode;\n  }\n\n  static List<XAttr> setINodeXAttrs(\n      FSDirectory fsd, final List<XAttr> existingXAttrs,\n      final List<XAttr> toSet, final EnumSet<XAttrSetFlag> flag)\n      throws IOException {\n    // Check for duplicate XAttrs in toSet\n    // We need to use a custom comparator, so using a HashSet is not suitable\n    for (int i = 0; i < toSet.size(); i++) {\n      for (int j = i + 1; j < toSet.size(); j++) {\n        if (toSet.get(i).equalsIgnoreValue(toSet.get(j))) {\n          throw new IOException(\"Cannot specify the same XAttr to be set \" +\n              \"more than once\");\n        }\n      }\n    }\n\n    // Count the current number of user-visible XAttrs for limit checking\n    int userVisibleXAttrsNum = 0; // Number of user visible xAttrs\n\n    // The XAttr list is copied to an exactly-sized array when it's stored,\n    // so there's no need to size it precisely here.\n    int newSize = (existingXAttrs != null) ? existingXAttrs.size() : 0;\n    newSize += toSet.size();\n    List<XAttr> xAttrs = Lists.newArrayListWithCapacity(newSize);\n\n    // Check if the XAttr already exists to validate with the provided flag\n    for (XAttr xAttr: toSet) {\n      boolean exist = false;\n      if (existingXAttrs != null) {","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java#L312-L348","documentation":"Error \"Cannot specify the same XAttr to be set more than once\" thrown in apache/hadoop.","triggerScenarios":"Calling setXAttrs with the same XAttr name appearing more than once in the list.","commonSituations":"See trigger scenarios.","solutions":["Pass each XAttr name only once per setXAttrs call; remove duplicates from the request."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}