Skip to content

SPR-7582 - Rebuild Advisor chain when interceptor list is updated in ProxyFactoryBean #1477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ protected final List<Advisor> getAdvisorsInternal() {
return this.advisors;
}

protected void clearAdvisors() {
this.advisors.clear();
updateAdvisorArray();
adviceChanged();
}

@Override
public void addAdvice(Advice advice) throws AopConfigException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public void setProxyInterfaces(Class<?>[] proxyInterfaces) throws ClassNotFoundE
*/
public void setInterceptorNames(String... interceptorNames) {
this.interceptorNames = interceptorNames;
initializeAdvisorChain();
}

/**
Expand Down Expand Up @@ -248,7 +249,9 @@ public void setBeanFactory(BeanFactory beanFactory) {
*/
@Override
public Object getObject() throws BeansException {
initializeAdvisorChain();
if (!this.advisorChainInitialized) {
initializeAdvisorChain();
}
if (isSingleton()) {
return getSingletonInstance();
}
Expand Down Expand Up @@ -430,9 +433,7 @@ private boolean isNamedBeanAnAdvisorOrAdvice(String beanName) {
* are unaffected by such changes.
*/
private synchronized void initializeAdvisorChain() throws AopConfigException, BeansException {
if (this.advisorChainInitialized) {
return;
}
clearAdvisors();

if (!ObjectUtils.isEmpty(this.interceptorNames)) {
if (this.beanFactory == null) {
Expand Down