{"record":{"id":"e5088d4d46f4a31f","repo":"spring-projects/spring-framework","slug":"cannot-add-advisor-configuration-is-frozen","errorCode":null,"errorMessage":"Cannot add advisor: Configuration is frozen.","messagePattern":"Cannot add advisor: Configuration is frozen\\.","errorType":"exception","errorClass":"AopConfigException","httpStatus":null,"severity":"error","filePath":"spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java","lineNumber":381,"sourceCode":"\t\taddAdvisor(index, b);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Add all the given advisors to this proxy configuration.\n\t * @param advisors the advisors to register\n\t */\n\tpublic void addAdvisors(Advisor... advisors) {\n\t\taddAdvisors(Arrays.asList(advisors));\n\t}\n\n\t/**\n\t * Add all the given advisors to this proxy configuration.\n\t * @param advisors the advisors to register\n\t */\n\tpublic void addAdvisors(Collection<Advisor> advisors) {\n\t\tif (isFrozen()) {\n\t\t\tthrow new AopConfigException(\"Cannot add advisor: Configuration is frozen.\");\n\t\t}\n\t\tif (!CollectionUtils.isEmpty(advisors)) {\n\t\t\tfor (Advisor advisor : advisors) {\n\t\t\t\tif (advisor instanceof IntroductionAdvisor introductionAdvisor) {\n\t\t\t\t\tvalidateIntroductionAdvisor(introductionAdvisor);\n\t\t\t\t}\n\t\t\t\tAssert.notNull(advisor, \"Advisor must not be null\");\n\t\t\t\tthis.advisors.add(advisor);\n\t\t\t}\n\t\t\tadviceChanged();\n\t\t}\n\t}\n\n\tprivate void validateIntroductionAdvisor(IntroductionAdvisor advisor) {\n\t\tadvisor.validateInterfaces();\n\t\t// If the advisor passed validation, we can make the change.\n\t\tfor (Class<?> ifc : advisor.getInterfaces()) {\n\t\t\taddInterface(ifc);","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java#L363-L399","documentation":"AdvisedSupport.addAdvisors(Collection) (line 379) refuses to append advisors when the configuration is frozen (isFrozen(), line 380). Frozen means the advisor chain has been locked for optimization/consistency, so no bulk addition is allowed.","triggerScenarios":"Calling addAdvisors(Collection) or addAdvisors(Advisor...) on a frozen AdvisedSupport instance.","commonSituations":"Explicitly setFrozen(true) for optimization then later trying to add advisors; mutating an Advised proxy that was built with frozen config; calling addAdvisors on a configuration snapshot taken from an already-built proxy.","solutions":["Ensure setFrozen(false) (the default) before adding advisors","If the proxy is already built and frozen, construct a fresh ProxyFactory, copy configuration, add advisors, and create a new proxy","Check ((Advised) proxy).isFrozen() before attempting the add and report/handle it"],"exampleFix":"// before\nadvised.setFrozen(true);\nadvised.addAdvisors(myAdvisors);\n\n// after\nadvised.setFrozen(false);\nadvised.addAdvisors(myAdvisors);","handlingStrategy":"validation","validationCode":"if (advised.isFrozen()) {\n  throw new IllegalStateException(\"Cannot add advisors: configuration is frozen\");\n}\nadvised.addAdvisors(advisors);","typeGuard":"private static boolean canAddAdvisor(AdvisedSupport a) {\n  return a != null && !a.isFrozen();\n}","tryCatchPattern":null,"preventionTips":["Keep frozen=false when runtime mutation is required","Build a new ProxyFactory if you must change a frozen proxy"],"tags":["spring-aop","advised","frozen","advisor"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}