{"record":{"id":"a10ec995df11c337","repo":"quarkusio/quarkus","slug":"manager-has-already-been-built","errorCode":null,"errorMessage":"manager has already been built","messagePattern":"manager has already been built","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/security/runtime/src/main/java/io/quarkus/security/runtime/QuarkusIdentityProviderManagerImpl.java","lineNumber":197,"sourceCode":"\n        Builder() {\n        }\n\n        private final Map<Class<? extends AuthenticationRequest>, List<IdentityProvider<? extends AuthenticationRequest>>> providers = new HashMap<>();\n        private final List<SecurityIdentityAugmentor> augmentors = new ArrayList<>();\n        private QuarkusPermissionSecurityIdentityAugmentor quarkusPermissionAugmentor = null;\n        private BlockingSecurityExecutor blockingExecutor;\n        private boolean built = false;\n\n        /**\n         * Adds an {@link IdentityProvider} implementation to this manager\n         *\n         * @param provider The provider\n         * @return this builder\n         */\n        public Builder addProvider(IdentityProvider<? extends AuthenticationRequest> provider) {\n            if (built) {\n                throw new IllegalStateException(\"manager has already been built\");\n            }\n            providers.computeIfAbsent(provider.getRequestType(), (a) -> new ArrayList<>()).add(provider);\n            return this;\n        }\n\n        /**\n         * Adds an augmentor that can modify the security identity that is provided by the identity store.\n         *\n         * @param augmentor The augmentor\n         * @return this builder\n         */\n        public Builder addSecurityIdentityAugmentor(SecurityIdentityAugmentor augmentor) {\n            if (augmentor instanceof QuarkusPermissionSecurityIdentityAugmentor quarkusPermissionAugmentor) {\n                this.quarkusPermissionAugmentor = quarkusPermissionAugmentor;\n            } else {\n                augmentors.add(augmentor);\n            }\n            return this;","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/security/runtime/src/main/java/io/quarkus/security/runtime/QuarkusIdentityProviderManagerImpl.java#L179-L215","documentation":"The QuarkusIdentityProviderManagerImpl.Builder is one-shot: after build() is called, its 'built' flag is set and any further addProvider(...) throws IllegalStateException. This prevents mutating the provider registry after the manager is in use.","triggerScenarios":"Holding a reference to the Builder and calling addProvider after manager construction; dynamically registering providers at runtime (e.g. in a startup callback that runs after the manager bean is created).","commonSituations":"Attempting to add providers from @Startup/@PostConstruct code that runs after the manager bean was produced; unit tests reusing a builder across manager instances.","solutions":["Call all addProvider(...) invocations before build(); restructure initialization so provider registration completes first.","Create a new Builder instance if you need a second manager with additional providers.","Register providers at build time via an IdentityProvider build step instead of runtime mutation."],"exampleFix":"// before\nvar m = b.build();\nb.addProvider(new ExtraProvider()); // throws\n// after\nb.addProvider(new ExtraProvider());\nvar m = b.build();","handlingStrategy":"validation","validationCode":"if (builtManagers.contains(builder)) throw new IllegalStateException(\"builder already used\");\n// or track in code: add all providers, then build, then discard builder","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never reuse a Builder after build()","Register providers at build time, not runtime","Structure tests to create a fresh builder per manager"],"tags":["quarkus","security","lifecycle","builder"],"backgroundTag":"illegal-state-builder-consumed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}