Browse Source

SpringBeanELResolver's setValue should not throw PropertyNotWritableException if provided value is identical to current bean instance

Issue: SPR-11502
(cherry picked from commit 7972b31)
pull/510/head
Juergen Hoeller 12 years ago
parent
commit
d642cd21bb
  1. 13
      spring-beans/src/main/java/org/springframework/beans/factory/access/el/SpringBeanELResolver.java

13
spring-beans/src/main/java/org/springframework/beans/factory/access/el/SpringBeanELResolver.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.beans.factory.access.el;
import java.beans.FeatureDescriptor; import java.beans.FeatureDescriptor;
import java.util.Iterator; import java.util.Iterator;
import javax.el.ELContext; import javax.el.ELContext;
import javax.el.ELException; import javax.el.ELException;
import javax.el.ELResolver; import javax.el.ELResolver;
@ -78,8 +77,14 @@ public abstract class SpringBeanELResolver extends ELResolver {
String beanName = property.toString(); String beanName = property.toString();
BeanFactory bf = getBeanFactory(elContext); BeanFactory bf = getBeanFactory(elContext);
if (bf.containsBean(beanName)) { if (bf.containsBean(beanName)) {
throw new PropertyNotWritableException( if (value == bf.getBean(beanName)) {
"Variable '" + beanName + "' refers to a Spring bean which by definition is not writable"); // Setting the bean reference to the same value is alright - can simply be ignored...
elContext.setPropertyResolved(true);
}
else {
throw new PropertyNotWritableException(
"Variable '" + beanName + "' refers to a Spring bean which by definition is not writable");
}
} }
} }
} }

Loading…
Cancel
Save