Issue 1:
Keith Garry Boyce opened SPR-1076 and commented

The call to getBean(factoryProcessorNames[i]) is flawed because it then must go out to get dependencies just to do ordering.. Below is an example where I had a problem. And below is a work around.. I think rather than implement order perhaps you might want to add an attribute to bean definition i.e: order= and use that instead.

What was happening is that to find the order of ConfigurationPlaceholderProcessor it had to satisfy dependency jconfigBean. The placeholder in that bean was supposed to be replaced first by propertyPlaceholderConfigurer so even though it gets the order for ConfigurationPlaceholderProcessor it's then to late to instantiate jconfigBean with appropriate placeholder from the propertyPlaceholderConfigurer since it had already been instantiated.

--------- flawed code -------

for (int i = 0; i < factoryProcessorNames.length; i++) {

if (Ordered.class.isAssignableFrom(getType(factoryProcessorNames[i]))) {

orderedFactoryProcessors.add(getBean(factoryProcessorNames[i]));

}

else {

nonOrderedFactoryProcessorNames.add(factoryProcessorNames[i]);

}

}

------------- Here is where I had problem ------------

<bean id="jmxExporter"
class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>

<entry key="Configuration:name=jmxConfig">
<ref local="jconfigBean" />
</entry>
</map>
</property>
</bean>

<bean id="jconfigBean" class="org.jconfig.jmx.ConfigHandler">
<property name="resourceName">
<value>${config.filename}</value>
</property>
<property name="configurationName">
<value>jmxConfig</value>
</property>
</bean>

<bean id="configurationFactory"
class="org.reactive.configuration.JConfigConfigurationFactory"
singleton="true">

<property name="fileName"><value>jmxConfig</value></property>
</bean>

<bean id="configuration"
factory-bean="configurationFactory"
factory-method="getConfiguration"
depends-on="jmxExporter"
/>

<bean id="configurationPlaceholderProcessor"
class="org.reactive.beans.factory.config.ConfigurationPlaceholderProcessor">
<property name="placeholderEvaluator">
<bean class="org.reactive.beans.factory.config.jconfig.JConfigPlaceholderEvaluator">
<property name="configuration">
<ref bean="configuration"/>
</property>
</bean>
</property>
<property name="order">
<value>2</value>
</property>
</bean>

<bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties">
<props>
<prop key="config.filename">dev_config.xml</prop>
</props>
</property>
<property name="systemPropertiesModeName">
<value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
</property>
<property name="order">
<value>1</value>
</property>
</bean>

------------- Here is possible (not ultimate) fix -----------

for (int i = 0; i < factoryProcessorNames.length; i++) {

if (Ordered.class.isAssignableFrom(getType(factoryProcessorNames[i]))) {

MutablePropertyValues values = getBeanFactory().getBeanDefinition(factoryProcessorNames[i]).getPropertyValues();

int order = Integer.MAX_VALUE;

if (values != null) {

PropertyValue orderValue = values.getPropertyValue("order");

if (orderValue != null) {

String orderInt = (String) orderValue.getValue();

if (orderInt != null) {

order = new Integer(orderInt).intValue();

}

}

}

OrderedFactoryHolder factoryProcessorHolder = new OrderedFactoryHolder(factoryProcessorNames[i],order);

orderedFactoryProcessorHolders.add(factoryProcessorHolder);

}

else {

nonOrderedFactoryProcessorNames.add(factoryProcessorNames[i]);

}

}

private class OrderedFactoryHolder implements Ordered {

/**
* @param factoryName
* @param order
*/
public OrderedFactoryHolder(String factoryProcessorName, int order) {
this.factoryProcessorName = factoryProcessorName;
this.order = order;
}
private String factoryProcessorName;
private int order;

/**
* @return Returns the factoryProcessorName.
*/
public String getFactoryProcessorName() {
return factoryProcessorName;
}
/* (non-Javadoc)
* @see org.springframework.core.Ordered#getOrder()
*/
public int getOrder() {
return order;
}

}

Affects: 1.2.1

Attachments:

AbstractApplicationContext.java (29.74 kB)

EagerPropertyPlaceholderConfigurer.java (3.85 kB)

PlaceHolderOrderTest.zip (1.72 kB)

Issue Links:

#6019 One BeanFactoryPostProcessor can't modify definition of a 2nd that has yet to run ("is duplicated by")

1 votes, 4 watchers

Issue 2:
Hans Desmet opened SPR-6735 and commented

When you use JDBC in the DAO layer a duplicate key violation that occurs when you insert a record or update a record

is translated to a DuplicateKeyException, which is fine !

When you use Hibernate in the DAO layer, a duplicate key violation is translated to the more general DataIntegrityViolationException,

Affects: 3.0 GA