{"record":{"id":"092e71d19b5d10aa","repo":"apache/hadoop","slug":"createparent-option-is-set-multiple-times","errorCode":null,"errorMessage":"CreateParent option is set multiple times","messagePattern":"CreateParent option is set multiple times","errorType":"validation","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java","lineNumber":590,"sourceCode":"          throw new  HadoopIllegalArgumentException(\n              \"CreateChecksumType option is set multiple times\");\n        }\n        checksumOpt = ((CreateOpts.ChecksumParam) iOpt).getValue();\n      } else if (CreateOpts.Perms.class.isInstance(iOpt)) {\n        if (permission != null) {\n          throw new HadoopIllegalArgumentException(\n              \"Perms option is set multiple times\");\n        }\n        permission = ((CreateOpts.Perms) iOpt).getValue();\n      } else if (CreateOpts.Progress.class.isInstance(iOpt)) {\n        if (progress != null) {\n          throw new HadoopIllegalArgumentException(\n              \"Progress option is set multiple times\");\n        }\n        progress = ((CreateOpts.Progress) iOpt).getValue();\n      } else if (CreateOpts.CreateParent.class.isInstance(iOpt)) {\n        if (createParent != null) {\n          throw new HadoopIllegalArgumentException(\n              \"CreateParent option is set multiple times\");\n        }\n        createParent = ((CreateOpts.CreateParent) iOpt).getValue();\n      } else {\n        throw new HadoopIllegalArgumentException(\"Unkown CreateOpts of type \" +\n            iOpt.getClass().getName());\n      }\n    }\n    if (permission == null) {\n      throw new HadoopIllegalArgumentException(\"no permission supplied\");\n    }\n\n\n    FsServerDefaults ssDef = getServerDefaults(f);\n    if (ssDef.getBlockSize() % ssDef.getBytesPerChecksum() != 0) {\n      throw new IOException(\"Internal error: default blockSize is\" + \n          \" not a multiple of default bytesPerChecksum \");\n    }","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L572-L608","documentation":"AbstractFileSystem.create accepts CreateOpts.CreateParent at most once; a second occurrence throws HadoopIllegalArgumentException. CreateParent governs whether missing parent directories are created, and the boolean must be resolved from a single option.","triggerScenarios":"Two CreateOpts.createParent(...) entries in one create() call, e.g. a convenience wrapper forcing parent creation appended after the caller's explicit createParent(false).","commonSituations":"Library convenience methods that \"make sure parents exist\" by appending the option regardless of what the caller passed; merge logic that concatenates option lists.","solutions":["Pass CreateOpts.createParent exactly once","Replace with CreateOpts.setOpt(CreateOpts.createParent(b), opts)","Dedupe the opts array by option class before create()"],"exampleFix":"// before\nfc.create(f, flag, CreateOpts.createParent(false),\n    CreateOpts.createParent(true));\n\n// after\nfc.create(f, flag, CreateOpts.createParent(true));","handlingStrategy":"validation","validationCode":"opts = CreateOpts.setOpt(CreateOpts.createParent(true), opts); // replaces existing CreateParent","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide parent-creation semantics in one place, not in stacked wrappers","Use CreateOpts.setOpt to override createParent","Dedupe opts by class in shared create wrappers"],"tags":["hadoop","file-create","options","varargs","validation"],"backgroundTag":"duplicate-create-option","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}