{"record":{"id":"270d7269cb5491f4","repo":"apache/hadoop","slug":"negative-length","errorCode":null,"errorMessage":"Negative length [{}]","messagePattern":"Negative length \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java","lineNumber":927,"sourceCode":"   * since archive files are part of bigger part files.\n   */\n  private static class HarFSDataInputStream extends FSDataInputStream {\n    /**\n     * Create an input stream that fakes all the reads/positions/seeking.\n     */\n    private static class HarFsInputStream extends FSInputStream\n        implements CanSetDropBehind, CanSetReadahead {\n      private long position, start, end;\n      //The underlying data input stream that the\n      // underlying filesystem will return.\n      private final FSDataInputStream underLyingStream;\n      //one byte buffer\n      private final byte[] oneBytebuff = new byte[1];\n      \n      HarFsInputStream(FileSystem fs, Path path, long start,\n          long length, int bufferSize) throws IOException {\n        if (length < 0) {\n          throw new IllegalArgumentException(\"Negative length [\"+length+\"]\");\n        }\n        underLyingStream = fs.open(path, bufferSize);\n        underLyingStream.seek(start);\n        // the start of this file in the part file\n        this.start = start;\n        // the position pointer in the part file\n        this.position = start;\n        // the end pointer in the part file\n        this.end = start + length;\n      }\n      \n      @Override\n      public synchronized int available() throws IOException {\n        long remaining = end - underLyingStream.getPos();\n        if (remaining > Integer.MAX_VALUE) {\n          return Integer.MAX_VALUE;\n        }\n        return (int) remaining;","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java#L909-L945","documentation":"Error \"Negative length [{}]\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java:927 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-negative length to the read call.","Validate the computed length before calling read; a negative value indicates an offset/length arithmetic bug."],"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-22T20:17:22.307Z"}