{"record":{"id":"137f5321e772ee1f","repo":"apache/pulsar","slug":"unsupported-longbitmap-type-other-getclass","errorCode":null,"errorMessage":"Unsupported LongBitmap type: <other.getClass()>","messagePattern":"Unsupported LongBitmap type: <other\\.getClass\\(\\)>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentRoaringBitmap.java","lineNumber":298,"sourceCode":"        // ensures rank(0x100000000L) counts all values in the uint32 range.\n        if (value > UINT32_SIZE) {\n            value = UINT32_SIZE;\n        }\n        long stamp = lock.readLock();\n        try {\n            return bitmap.rank((int) (value - 1));\n        } finally {\n            lock.unlockRead(stamp);\n        }\n    }\n\n    @Override\n    public void or(LongBitmap other) {\n        if (other == this) {\n            return;\n        }\n        if (!(other instanceof ConcurrentRoaringBitmap)) {\n            throw new IllegalArgumentException(\"Unsupported LongBitmap type: \" + other.getClass());\n        }\n        ConcurrentRoaringBitmap that = (ConcurrentRoaringBitmap) other;\n\n        // Acquire this.writeLock + that.readLock in identityHashCode order so concurrent\n        // A.or(B) and B.or(A) don't deadlock. Fall back to inner bitmap identity on collision.\n        boolean thisFirst;\n        int outerCmp = Integer.compare(\n                System.identityHashCode(this), System.identityHashCode(that));\n        if (outerCmp != 0) {\n            thisFirst = outerCmp < 0;\n        } else {\n            thisFirst = System.identityHashCode(this.bitmap) < System.identityHashCode(that.bitmap);\n        }\n\n        if (thisFirst) {\n            long thisStamp = this.lock.writeLock();\n            try {\n                long thatStamp = that.lock.readLock();","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentRoaringBitmap.java#L280-L316","documentation":"ConcurrentRoaringBitmap.or(LongBitmap) only supports bitwise-OR with another ConcurrentRoaringBitmap; passing any other LongBitmap implementation throws IllegalArgumentException. Locking order for the merge is only defined between instances of this class.","triggerScenarios":"Calling bitmap.or(otherBitmap) where otherBitmap is a foreign LongBitmap implementation (custom class or a different library's roaring bitmap wrapper).","commonSituations":"Mixing bitmap implementations across plugins/modules, or after a library swap where a different LongBitmap impl is returned by an API.","solutions":["Ensure both operands are ConcurrentRoaringBitmap instances; copy foreign bitmaps via deserialization into a ConcurrentRoaringBitmap first","Guard with `other instanceof ConcurrentRoaringBitmap` before calling or()","Standardize on one LongBitmap implementation across the codebase"],"exampleFix":"// before\nbitmap.or(foreignBitmap); // throws\n// after\nif (foreignBitmap instanceof ConcurrentRoaringBitmap) {\n    bitmap.or(foreignBitmap);\n} else {\n    ConcurrentRoaringBitmap converted =\n        ConcurrentRoaringBitmap.deserialize(foreignBitmap.serialize());\n    bitmap.or(converted);\n}","handlingStrategy":"type-guard","validationCode":"if (!(other instanceof ConcurrentRoaringBitmap)) {\n    other = ConcurrentRoaringBitmap.deserialize(other.serialize());\n}\nbm.or(other);","typeGuard":"static boolean isConcurrentRoaring(LongBitmap b) {\n    return b instanceof ConcurrentRoaringBitmap;\n}","tryCatchPattern":"try {\n    bm.or(other);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"Mixing LongBitmap implementations: \" + e.getMessage(), e);\n}","preventionTips":["Use a single LongBitmap implementation project-wide","Convert foreign bitmaps at module boundaries","Check method contracts before passing interface-typed arguments"],"tags":["java","illegal-argument","type-mismatch"],"backgroundTag":"unsupported-bitmap-type","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}