{"record":{"id":"91e01fe43260f8fd","repo":"apache/druid","slug":"cannot-convert-s","errorCode":null,"errorMessage":"Cannot convert [%s]","messagePattern":"Cannot convert \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/collections/bitmap/ConciseBitmapFactory.java","lineNumber":96,"sourceCode":"  }\n\n  @Override\n  public MutableBitmap makeEmptyMutableBitmap()\n  {\n    return new WrappedConciseBitmap();\n  }\n\n  @Override\n  public ImmutableBitmap makeEmptyImmutableBitmap()\n  {\n    return WRAPPED_IMMUTABLE_CONCISE_BITMAP;\n  }\n\n  @Override\n  public ImmutableBitmap makeImmutableBitmap(MutableBitmap mutableBitmap)\n  {\n    if (!(mutableBitmap instanceof WrappedConciseBitmap)) {\n      throw new ISE(\"Cannot convert [%s]\", mutableBitmap.getClass());\n    }\n    return new WrappedImmutableConciseBitmap(\n        ImmutableConciseSet.newImmutableFromMutable(\n            ((WrappedConciseBitmap) mutableBitmap).getBitmap()\n        )\n    );\n  }\n\n  @Override\n  public ImmutableBitmap mapImmutableBitmap(ByteBuffer b)\n  {\n    return new WrappedImmutableConciseBitmap(b.asIntBuffer());\n  }\n\n  @Override\n  public ImmutableBitmap union(Iterable<ImmutableBitmap> b)\n      throws ClassCastException\n  {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/collections/bitmap/ConciseBitmapFactory.java#L78-L114","documentation":"ConciseBitmapFactory.makeImmutableBitmap only knows how to convert a WrappedConciseBitmap (its own mutable type). Passing any other MutableBitmap implementation throws IllegalStateException naming the offending class, guarding against mixing bitmap implementations within one factory.","triggerScenarios":"Calling makeImmutableBitmap() with a mutable bitmap created by a different factory (e.g. WrappedRoaringBitmap or RoaringBitmapFactory's mutable type) instead of one from ConciseBitmapFactory.makeMutableBitmap().","commonSituations":"Configuring different bitmap factories for different components (e.g. index vs query) so bitmaps cross factory boundaries; refactoring code that switched to Roaring while a utility still uses Concise; passing generic MutableBitmap parameters built elsewhere.","solutions":["Create the mutable bitmap from the same factory: use conciseFactory.makeMutableBitmap() and pass that to makeImmutableBitmap()","Standardize on one bitmap factory across the system (druid.processing.bitmap.type config)","If conversion between types is needed, copy via iteration: create a new WrappedConciseBitmap and add all bits from the source","Check where the MutableBitmap originated — a factory mismatch elsewhere is the root cause"],"exampleFix":"// before\nMutableBitmap mutable = roaringFactory.makeMutableBitmap();\nImmutableBitmap immutable = conciseFactory.makeImmutableBitmap(mutable); // ISE\n// after\nMutableBitmap mutable = conciseFactory.makeMutableBitmap();\nmutable.or(mutableFromOtherFactory);\nImmutableBitmap immutable = conciseFactory.makeImmutableBitmap(mutable);","handlingStrategy":"type-guard","validationCode":"if (!(mutableBitmap instanceof WrappedConciseBitmap)) { throw new IllegalArgumentException(\"need a bitmap from ConciseBitmapFactory\"); }","typeGuard":"static boolean isConciseMutable(MutableBitmap b) { return b instanceof WrappedConciseBitmap; }","tryCatchPattern":"try { ImmutableBitmap im = factory.makeImmutableBitmap(mb); } catch (IllegalStateException e) { /* wrong factory: rebuild via makeMutableBitmap and copy bits */ }","preventionTips":["Always pair a bitmap with the factory that created it","Standardize druid.processing.bitmap.type across the cluster","When converting, copy bit-by-bit into the target factory's mutable type"],"tags":["java","bitmap","type-mismatch"],"backgroundTag":"incompatible-source-type","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}