Skip to content
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

Regression: ResourceEditor in 3.0 does not ignore unresolvable placeholders, but it did in 2.5.6 [SPR-6321] #10987

Closed
spring-projects-issues opened this issue Nov 10, 2009 · 5 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 10, 2009

Dave Syer opened SPR-6321 and commented

Regression: ResourceEditor in 3.0 does not ignore unresolvable placeholders, but it did in 2.5.6. At least it would make sense to make the old behaviour an option if not the default.

The problem is possibly more ubiquitous, since all clients of org.springframework.util.SystemPropertyUtils.resolvePlaceholders(String) may be affected, but I'm not sure which of those is going to change its behaviour in 3.0.


Affects: 3.0 RC1

Issue Links:

Referenced from: commits 38f1383, 568e6a3

1 votes, 1 watchers

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Nov 11, 2009

Dave Syer commented

A new feature in 3.0 is the use of ${key:defaultValue} syntax for defaulting missing values. This is probably better than the old behaviour anyway, so I'm going to leave the ResourceEditor alone and assume that the other cases are also best dealt with in this way. Added some javadocs and a unit test.

@spring-projects-issues
Copy link
Collaborator Author

Matt Goldspink commented

Just to add we hit this issue also. After asking via support channels it seemed like this was an intentional change, but it is still a pain because it means doing something like:

<bean id="PropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
   <property name="locations">
      <list>
         <value>classpath:com/myapp/${CONFIG_MODE}.properties</value>
         <value>classpath:com/myapp/local/${CONFIG_MODE}.${LOCATION}.properties</value>
      </list>
   </property>
   <property name="ignoreResourceNotFound" value="true" />
   <property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>

In some instances of the application we would not pass in a LOCATION system property because only certain regions need to override properties. This no longer works in 3.0.RC1 and we worked around it by doing the following:

<bean id="PropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
   <property name="locations">
      <list>
         <value>classpath:com/myapp/${CONFIG_MODE}.properties</value>
         <value>classpath:com/myapp/local/${CONFIG_MODE}.${LOCATION:foo}.properties</value>
      </list>
   </property>
   <property name="ignoreResourceNotFound" value="true" />
   <property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>

and use the new defaulting in Spring to avoid this issue. It seems a bit counterintuitive given that the settings on the PropertyPlaceholderConfigurer say "ignoreUnresolvablePlaceholders" and "ignoreResourceNotFound". I understand that they don't apply to the resources in the locations property because of the Resource objects are created before the rest of the bean definition has been applied, but it would be nice if there was a way to have the old behaviour, though given the workaround its not all that bad.

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

OK, Matt, I give in. The old behaviour was better, but it does mean that the ResourceEditor has to behave this way for all applications, not just the PropertyPlaceholderConfigurer,

@spring-projects-issues
Copy link
Collaborator Author

Matt Goldspink commented

I've got to admit the workaround is simple enough so its not a huge issue. I guess I'm still looking for the benefits of the new behaviour when its being used outside of the PropertyPlaceholderConfigurer. But since you've re-opened this now I'm happy :) Thanks Dave

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

I guess the benefit of the new behaviour is a fast failure with a more meaningful exception than before. But the PropertyPlaceholderConfigurer is so ubiquitous and it has its own ignoreResourceNotFound, so on balance I think it's better not to regress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant