{"record":{"id":"fbda88c33adea32d","repo":"apache/druid","slug":"number-d-exceeds-range-of-integer-max-value","errorCode":null,"errorMessage":"Number [%d] exceeds range of Integer.MAX_VALUE","messagePattern":"Number \\[(.+?)\\] exceeds range of Integer\\.MAX_VALUE","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java","lineNumber":49,"sourceCode":"  public HumanReadableBytes(String bytes)\n  {\n    this.bytes = HumanReadableBytes.parse(bytes);\n  }\n\n  public HumanReadableBytes(long bytes)\n  {\n    this.bytes = bytes;\n  }\n\n  public long getBytes()\n  {\n    return bytes;\n  }\n\n  public int getBytesInInt()\n  {\n    if (bytes > Integer.MAX_VALUE) {\n      throw new ISE(\"Number [%d] exceeds range of Integer.MAX_VALUE\", bytes);\n    }\n\n    return (int) bytes;\n  }\n\n  @Override\n  public boolean equals(Object thatObj)\n  {\n    if (thatObj == null) {\n      return false;\n    }\n    if (thatObj instanceof HumanReadableBytes) {\n      return bytes == ((HumanReadableBytes) thatObj).bytes;\n    } else {\n      return false;\n    }\n  }\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/HumanReadableBytes.java#L31-L67","documentation":"HumanReadableBytes.getBytesInInt throws this ISE when the configured byte value exceeds Integer.MAX_VALUE but the caller needs it as an int (e.g. an in-memory buffer size). It prevents silent overflow/truncation when downcasting the internal long to int.","triggerScenarios":"Configuring a HumanReadableBytes property (e.g. druid.processing.buffer.sizeBytes) with a value like \"4g\" or larger and calling getBytesInInt(), since 4GiB > 2^31-1.","commonSituations":"Setting druid.processing.buffer.sizeBytes to 4g/8g on large-memory machines where the configuration expects an int-sized buffer; copy-pasting memory sizes from other JVM settings.","solutions":["Reduce the configured value to at most 2147483647 bytes (e.g. use \"3g\" or less)","Use \"2000000000\" or a value like \"2g\" for druid.processing.buffer.sizeBytes","If a larger buffer is genuinely needed, check whether the consuming setting accepts a long variant or allocate multiple buffers","Catch the ISE and clamp to Integer.MAX_VALUE with a logged warning"],"exampleFix":"// before\ndruid.processing.buffer.sizeBytes: \"4g\" // exceeds Integer.MAX_VALUE\n// after\ndruid.processing.buffer.sizeBytes: \"2g\"","handlingStrategy":"validation","validationCode":"HumanReadableBytes v = HumanReadableBytes.valueOf(configValue);\nif (v.getBytes() > Integer.MAX_VALUE) {\n  throw new IllegalArgumentException(\"Value \" + configValue + \" exceeds Integer.MAX_VALUE; use <= 2147483647 bytes\");\n}\nint bufSize = v.getBytesInInt();","typeGuard":"static boolean fitsInInt(HumanReadableBytes bytes) {\n  return bytes.getBytes() <= Integer.MAX_VALUE;\n}","tryCatchPattern":"try {\n  int n = humanReadableBytes.getBytesInInt();\n} catch (ISE e) {\n  log.warn(\"Configured size exceeds Integer.MAX_VALUE, clamping to 2GB\");\n  int n = Integer.MAX_VALUE;\n}","preventionTips":["Keep int-sized settings (like druid.processing.buffer.sizeBytes) at or below 2g","Verify units: 4g is 4294967296 bytes, larger than Integer.MAX_VALUE","Compute limits before deploying to large-memory machines","Document the int ceiling next to each int-typed config key"],"tags":["configuration","integer-overflow","bytes"],"backgroundTag":"value-out-of-range","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}