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

BeanWrapper fails in case of read/write method mismatch (e.g. EhCacheFactoryBean.setMemoryStoreEvictionPolicy) [SPR-11361] #15987

Closed
spring-projects-issues opened this issue Jan 27, 2014 · 1 comment
Assignees
Labels
in: core status: backported type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Jan 27, 2014

Brandon Mintern opened SPR-11361 and commented

We have an applicationContext-common-authorization.xml file with the following component:

<bean id="aclCacheFactory" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
    <property name="cacheManager">
        <ref local="cacheManager"/>
    </property>
    <property name="maxElementsInMemory" value="30000"/>
    <property name="eternal" value="false"/>
    <property name="timeToIdle" value="3600"/>
    <property name="timeToLive" value="7200"/>
    <property name="overflowToDisk" value="false"/>
    <property name="memoryStoreEvictionPolicy" value="LRU"/>
    <property name="diskPersistent" value="false"/>
    <property name="cacheName" value="aclCache"/>
</bean>

This fails on memoryStoreEvictionPolicy. I can trace down all the way to ehCache's CacheConfiguration, and all is well. After it returns, though, BeanWrapperImpl:1152 calls:

writeMethod.invoke(this.object, value);

The writeMethod accepts a String, but the value passed in is a MemoryStoreEvictionPolicy enum.

Is this a bug? Or do I simply need to change my configuration (perhaps using memoryStoreEvictionPolicyFromObject instead)?

This worked fine before our upgrade to Spring 4.

When I remove the memoryStoreEvictionPolicy line (LRU is the default, anyway), the server starts up normally.


Affects: 3.2.6, 4.0 GA

Backported to: 3.2.7

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 27, 2014

Juergen Hoeller commented

This turned out to be a problem with BeanWrapperImpl's type resolution in case of inconsistencies between the read and write method of a target property:

In EhCache's case, the getMemoryStoreEvictionPolicy method returns the enum, but setMemoryStoreEvictionPolicy takes a String argument...

As of Spring 4.0.1, we're correctly choosing the write method's argument type for conversion purposes, if there is such a mismatch.

Juergen

@spring-projects-issues spring-projects-issues added type: bug status: backported in: core labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.0.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: backported type: bug
Projects
None yet
Development

No branches or pull requests

2 participants