apache/cassandra · warning · java.lang.UnsupportedOperationException

todo

Error message

todo

What it means

BTreeMap's NavigableMap subMap(fromKey, fromInclusive, toKey, toInclusive) is an unimplemented stub that unconditionally throws UnsupportedOperationException with the placeholder message "todo". The btree-based immutable map implements only a subset of the NavigableMap API.

Solutions

  1. Do not call the ranged subMap on BTreeMap; use BTree.slice() utilities or iterate the map's entrySet with your own bounds check.
  2. Replace BTreeMap with java.util.TreeMap where ranged views are required.
  3. Implement the method if you control the fork — it should return a bounded view over BTree.slice(tree, lower, lowerInclusive, upper, upperInclusive).
  4. Guard the call site with an instanceof check and fall back to a copy-based approach.

Example fix

// before
NavigableMap<K,V> view = btreeMap.subMap(from, true, to, false); // throws
// after
Iterator<Map.Entry<K,V>> it = BTree.slice(btreeTree, comparator, from, true, to, false, true);
Defensive patterns

Strategy: try-catch

Type guard

boolean supportsRanges(Map<?,?> m) { return !(m instanceof BTreeMap) && (m instanceof NavigableMap); }

Try / catch

try { return map.subMap(from, true, to, false); } catch (UnsupportedOperationException e) { /* fall back to filtered iteration */ }

Prevention

When it happens

Trigger: Calling btreeMap.subMap(fromKey, fromInclusive, toKey, toInclusive) — the 4-argument inclusive/exclusive range view — on any BTreeMap instance.

Common situations: Code written against the general NavigableMap interface being passed a BTreeMap; refactoring code that previously used TreeMap to use BTreeMap; generic utility code iterating map ranges.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/e2f72bbb57666bd6. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/utils/btree/BTreeMap.java:178

                              new KeyComparator<>(reversed), new AsymmetricKeyComparator<>(reversed));
    }

    @Override
    public NavigableSet<K> navigableKeySet()
    {
        throw new UnsupportedOperationException("todo");
    }

    @Override
    public NavigableSet<K> descendingKeySet()
    {
        throw new UnsupportedOperationException("todo");
    }

    @Override
    public NavigableMap<K, V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
    {
        throw new UnsupportedOperationException("todo");
    }

    @Override
    public NavigableMap<K, V> headMap(K toKey, boolean inclusive)
    {
        throw new UnsupportedOperationException("todo");
    }

    @Override
    public NavigableMap<K, V> tailMap(K fromKey, boolean inclusive)
    {
        throw new UnsupportedOperationException("todo");
    }

    @Override
    public Comparator<K> comparator()
    {
        return comparator.keyComparator;

View on GitHub (pinned to 88fd0f6a0e)