{"record":{"id":"8c9d18b14b2f461a","repo":"quarkusio/quarkus","slug":"duplicate-key-s-attempted-merging-values-s-and","errorCode":null,"errorMessage":"Duplicate key %s (attempted merging values %s and %s)","messagePattern":"Duplicate key (.+?) \\(attempted merging values (.+?) and (.+?)\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java","lineNumber":953,"sourceCode":"        private final Map<String, Handler> additionalNamedHandlersMap;\n        private final ErrorManager errorManager;\n        private final Collection<LogCleanupFilterElement> filterElements;\n\n        private final ShutdownNotifier shutdownNotifier;\n\n        public AdditionalNamedHandlersConsumer(Map<String, Handler> additionalNamedHandlersMap, ErrorManager errorManager,\n                Collection<LogCleanupFilterElement> filterElements, ShutdownNotifier shutdownNotifier) {\n            this.additionalNamedHandlersMap = additionalNamedHandlersMap;\n            this.errorManager = errorManager;\n            this.filterElements = filterElements;\n            this.shutdownNotifier = shutdownNotifier;\n        }\n\n        @Override\n        public void accept(String name, Handler handler) {\n            Handler previous = additionalNamedHandlersMap.putIfAbsent(name, handler);\n            if (previous != null) {\n                throw new IllegalStateException(String.format(\n                        \"Duplicate key %s (attempted merging values %s and %s)\",\n                        name, previous, handler));\n            }\n            handler.setErrorManager(errorManager);\n            handler.setFilter(new LogCleanupFilter(filterElements, shutdownNotifier));\n        }\n    }\n\n    public static class ShutdownNotifier implements ShutdownListener {\n        volatile boolean shutdown;\n\n        @Override\n        public void shutdown(ShutdownNotification notification) {\n            shutdown = true;\n            notification.done();\n        }\n    }\n}","sourceCodeStart":935,"sourceCodeEnd":971,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java#L935-L971","documentation":"When wiring additional named handlers (e.g. from other extensions via AdditionalLoggingSetup / named handler maps), the collector uses putIfAbsent and throws IllegalStateException \"Duplicate key %s (attempted merging values ...)\" if two handlers share the same name. This prevents silently overwriting a handler registered by another part of the application.","triggerScenarios":"Two sources (e.g. an extension recorder and application configuration) register additional named log handlers with the same name into the additional named handlers map during logging setup.","commonSituations":"Multiple extensions each registering a named handler with a generic name like \"MAIN\"; duplicate AdditionalLoggingSetup build items; a custom handler registered both via config and via a recorder.","solutions":["Rename one of the handlers so names are unique across all registration sources","Find which extensions/build items register the conflicting handler and remove or rename the duplicate","If you own the code, use distinct handler names per functional area"],"exampleFix":"// before: two recorders both do namedHandlers.put(\"MAIN\", handler)\n// after\nnamedHandler(\"APP_MAIN\", appHandler);\nnamedHandler(\"EXT_MAIN\", extHandler);","handlingStrategy":"try-catch","validationCode":"// detect duplicates before registering additional named handlers\nif (additionalNamedHandlersMap.containsKey(name)) throw new IllegalStateException(\"Handler already registered: \" + name);","typeGuard":null,"tryCatchPattern":"try { registerAdditionalHandlers(map); } catch (IllegalStateException e) { if (e.getMessage().startsWith(\"Duplicate key\")) log.error(\"Rename one of the conflicting named handlers\"); else throw e; }","preventionTips":["Namespace handler names per extension (e.g. \"myext-main\")","Avoid generic names like MAIN or DEFAULT for named handlers","Audit extensions that contribute AdditionalLoggingSetup handlers"],"tags":["logging","duplicate-key","extensions"],"backgroundTag":"duplicate-handler-name","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"}