{"record":{"id":"386fa2171cf74805","repo":"apache/hadoop","slug":"absolutepath-is-a-file","errorCode":null,"errorMessage":"absolutePath + \" is a file\"","messagePattern":"absolutePath \\+ \" is a file\"","errorType":"exception","errorClass":"FileAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BaiduBosFileSystem.java","lineNumber":659,"sourceCode":"        null,\n        owner,\n        group,\n        null,\n        path.makeQualified(this),\n        FileStatus.NONE);\n  }\n\n  @Override\n  public boolean mkdirs(Path f, FsPermission permission)\n      throws IOException {\n    Path absolutePath = makeAbsolute(f);\n\n    List<Path> paths = new ArrayList<>();\n    do {\n      try {\n        FileStatus fileStatus = getFileStatus(absolutePath);\n        if (fileStatus.isFile()) {\n          throw new FileAlreadyExistsException(\n              absolutePath + \" is a file\");\n        } else {\n          break;\n        }\n      } catch (FileNotFoundException e) {\n        paths.add(0, absolutePath);\n        absolutePath = absolutePath.getParent();\n      }\n    } while (!pathToKey(absolutePath).isEmpty());\n\n    boolean result = true;\n    for (Path path : paths) {\n      result &= mkdir(path);\n    }\n    return result;\n  }\n\n  private boolean mkdir(Path f) throws IOException {","sourceCodeStart":641,"sourceCodeEnd":677,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BaiduBosFileSystem.java#L641-L677","documentation":"TypedBytesWritableInput.readArray(ArrayWritable aw) decodes a typed-bytes VECTOR into an ArrayWritable whose element class is TypedBytesWritable. If you pass a reusable ArrayWritable whose value class is anything else, it throws RuntimeException 'value class has to be TypedBytesWritable' rather than silently filling an array with mismatched elements. Passing null is fine — a correctly-typed ArrayWritable is allocated for you.","triggerScenarios":"Calling readArray(aw) with an ArrayWritable constructed over another Writable class (e.g. new ArrayWritable(Text.class)) as the reuse buffer; a common optimization pattern (object reuse) that is invalid for this reader because vector elements are always re-wrapped as TypedBytesWritable via in.readRaw().","commonSituations":"Reusing buffers from a different InputFormat's reader (e.g. KeyValueTextInputFormat's Text arrays) with typed-bytes input; copy-pasted record-reader code that pre-allocates ArrayWritable with the 'wrong' generic; refactoring a job from text input to typed bytes without updating the reuse object.","solutions":["Pass null and let the reader allocate: readArray(null) returns a new ArrayWritable(TypedBytesWritable.class).","Or allocate the reuse object correctly once: new ArrayWritable(TypedBytesWritable.class).","After reading, unwrap elements with ((TypedBytesWritable) aw.get()[i]).getValue() — do not cast elements to your previous class.","If you need typed values, convert after reading instead of forcing the reader's array class."],"exampleFix":"// before\nArrayWritable aw = new ArrayWritable(Text.class);\nreader.readArray(aw); // throws: value class has to be TypedBytesWritable\n\n// after\nArrayWritable aw = reader.readArray(null); // ArrayWritable(TypedBytesWritable.class)\nTypedBytesWritable[] elems = (TypedBytesWritable[]) aw.toArray();","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isTypedBytesArrayWritable(org.apache.hadoop.io.ArrayWritable aw) {\n  return aw == null || aw.getValueClass().equals(\n      org.apache.hadoop.typedbytes.TypedBytesWritable.class);\n}","tryCatchPattern":null,"preventionTips":["Call readArray(null) unless you allocated the reuse object as new ArrayWritable(TypedBytesWritable.class).","Do not share reuse buffers across InputFormats with different value classes.","Cast elements to TypedBytesWritable after reading."],"tags":["hadoop","typedbytes","type-mismatch","arraywritable","serialization"],"backgroundTag":"type-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}