{"record":{"id":"7375d7cd18069d46","repo":"apache/druid","slug":"got-an-exception-while-parsing-file-s","errorCode":null,"errorMessage":"Got an exception while parsing file [%s]","messagePattern":"Got an exception while parsing file \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/WhiteListBasedDruidToTimelineEventConverter.java","lineNumber":225,"sourceCode":"  private ImmutableSortedMap<String, ImmutableList<String>> readMap(final String mapPath)\n  {\n    String fileContent;\n    String actualPath = mapPath;\n    try {\n      if (Strings.isNullOrEmpty(mapPath)) {\n        URL defaultWhiteListMapUrl = this.getClass().getClassLoader().getResource(\"defaultWhiteListMap.json\");\n        actualPath = defaultWhiteListMapUrl.getFile();\n        LOGGER.info(\"using default whiteList map located at [%s]\", actualPath);\n        fileContent = Resources.toString(defaultWhiteListMapUrl, StandardCharsets.UTF_8);\n      } else {\n        fileContent = Files.asCharSource(new File(mapPath), StandardCharsets.UTF_8).read();\n      }\n      return mapper.readerFor(new TypeReference<ImmutableSortedMap<String, ImmutableList<String>>>()\n      {\n      }).readValue(fileContent);\n    }\n    catch (IOException e) {\n      throw new ISE(e, \"Got an exception while parsing file [%s]\", actualPath);\n    }\n  }\n\n  @Override\n  public boolean equals(Object o)\n  {\n    if (this == o) {\n      return true;\n    }\n    if (o == null || getClass() != o.getClass()) {\n      return false;\n    }\n\n    WhiteListBasedDruidToTimelineEventConverter that = (WhiteListBasedDruidToTimelineEventConverter) o;\n\n    if (namespacePrefix != null ? !namespacePrefix.equals(that.namespacePrefix) : that.namespacePrefix != null) {\n      return false;\n    }","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/WhiteListBasedDruidToTimelineEventConverter.java#L207-L243","documentation":"mergeBloomFilterByteBuffers computes each buffer's serialized length as START_OF_SERIALIZED_LONGS + (declared bitset longs * Long.BYTES) and requires the two lengths to be equal before merging. If they differ, it throws this IllegalArgumentException. The serialized length encodes numBits, so this check rejects bloom filters of different sizes.","triggerScenarios":"Calling BloomKFilter.mergeBloomFilterByteBuffers(bf1Buffer, bf2Buffer, start1, start2) with buffers whose declared bitset lengths (bytes at offset 1+start) differ, e.g. filters built with different numBits parameters.","commonSituations":"Merging bloom filter results from query stages that used different bloomFilterNumBits settings; merging base and offset buffers pointing at filters of different sizes; combining filters serialized by different configurations or external tools.","solutions":["Use filters produced with the same bloomFilterNumBits (and numHashFunctions) everywhere before merging.","Check START_OF_SERIALIZED_LONGS + (getInt(1+start) * Long.BYTES) for both buffers yourself and route mismatched filters to separate merges.","Ensure start offsets (bf1Start/bf2Start) actually point at filter headers, not mid-buffer, so the computed lengths are the real ones.","Catch IllegalArgumentException and report which of the two buffers has the wrong size."],"exampleFix":"// before\nBloomKFilter.mergeBloomFilterByteBuffers(buf1, buf2, 0, 0); // throws if sizes differ\n\n// after\nint len1 = BloomKFilter.START_OF_SERIALIZED_LONGS + (buf1.getInt(1) * Long.BYTES);\nint len2 = BloomKFilter.START_OF_SERIALIZED_LONGS + (buf2.getInt(1) * Long.BYTES);\nif (len1 != len2) {\n  throw new IllegalStateException(\"cannot merge bloom filters of different sizes: \" + len1 + \" vs \" + len2);\n}\nBloomKFilter.mergeBloomFilterByteBuffers(buf1, buf2, 0, 0);","handlingStrategy":"validation","validationCode":"int serializedLen(ByteBuffer buf, int start) {\n  int longs = buf.duplicate().order(ByteOrder.BIG_ENDIAN).getInt(1 + start);\n  return BloomKFilter.START_OF_SERIALIZED_LONGS + longs * Long.BYTES;\n}\n// call: assert serializedLen(bf1Buffer, bf1Start) == serializedLen(bf2Buffer, bf2Start);","typeGuard":"boolean sameSize(ByteBuffer b1, int s1, ByteBuffer b2, int s2) {\n  return serializedLen(b1, s1) == serializedLen(b2, s2);\n}","tryCatchPattern":"try {\n  BloomKFilter.mergeBloomFilterByteBuffers(bf1Buffer, bf2Buffer, start1, start2);\n} catch (IllegalArgumentException e) {\n  throw new IllegalStateException(\"Refusing to merge bloom filters of different sizes; align bloomFilterNumBits across stages\", e);\n}","preventionTips":["Use a single bloomFilterNumBits value for all stages of an aggregation.","Confirm start offsets point at the beginning of each serialized filter header.","Compare declared lengths yourself before invoking merge when inputs come from external sources."],"tags":["bloom-filter","argument-validation","aggregation","druid"],"backgroundTag":"invalid-argument-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}