{"record":{"id":"f43ecec986daf553","repo":"quarkusio/quarkus","slug":"unsupportedoperationexception","errorCode":null,"errorMessage":"UnsupportedOperationException","messagePattern":"UnsupportedOperationException","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/ImmutableSubstringMap.java","lineNumber":222,"sourceCode":"                        }\n\n                        @Override\n                        public String next() {\n                            if (!hasNext()) {\n                                throw new NoSuchElementException();\n                            }\n                            String ret = (String) map[pos];\n\n                            pos += 2;\n                            while (pos < table.length && tMap[pos] == null) {\n                                pos += 2;\n                            }\n                            return ret;\n                        }\n\n                        @Override\n                        public void remove() {\n                            throw new UnsupportedOperationException();\n                        }\n                    };\n                }\n            };\n\n        }\n\n        ImmutableSubstringMap<V> build() {\n            return new ImmutableSubstringMap<>(table);\n        }\n    }\n}\n","sourceCodeStart":204,"sourceCodeEnd":235,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/security/ImmutableSubstringMap.java#L204-L235","documentation":"The iterator returned by ImmutableSubstringMap's values/lookup does not support element removal: calling remove() on it unconditionally throws UnsupportedOperationException. This is an immutable snapshot structure, so mutation through the iterator is intentionally unsupported.","triggerScenarios":"Calling Iterator.remove() on an iterator obtained from ImmutableSubstringMap (e.g. while iterating its values) or any library code that tries to mutate through it.","commonSituations":"Developers porting mutable-map iteration code, or trying to prune entries while iterating a read-only lookup structure.","solutions":["Do not call remove() on this iterator; build a new ImmutableSubstringMap without the unwanted entries instead.","Collect the keys/values you want to drop and rebuild the map.","If mutation is required, use a mutable Map during construction before wrapping in ImmutableSubstringMap."],"exampleFix":"// before\nit.remove();\n// after\nMap<String,V> copy = new HashMap<>(existing);\ncopy.remove(key);\nImmutableSubstringMap<V> updated = rebuild(copy);","handlingStrategy":"try-catch","validationCode":"// avoid mutation: do not call remove() on ImmutableSubstringMap iterators","typeGuard":null,"tryCatchPattern":"try (var it = map.iterator()) {\n  while (it.hasNext()) { process(it.next()); }\n} catch (UnsupportedOperationException e) {\n  // snapshot iterator: rebuild map without the entry instead of removing\n}","preventionTips":["Treat ImmutableSubstringMap as read-only","Rebuild the map to remove entries","Never call Iterator.remove() on snapshot iterators"],"tags":["quarkus","unsupported-operation","iterator","immutable"],"backgroundTag":"unsupported-operation","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}