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

ConcurrentMapCacheManager's storeByValue does not pick up ClassLoader [SPR-14314] #18886

Closed
spring-projects-issues opened this issue May 28, 2016 · 2 comments
Assignees
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 May 28, 2016

Kazuki Shimizu opened SPR-14314 and commented

I've tried a new feature of cacheing supported at Spring 4.3.
I've used the storeByValue property of ConcurrentMapCacheManager as follow:

@EnableCaching
@Configuration
public class CacheConfig {
    @Bean
    CacheManager cacheManager() {
        ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager("configs");
        cacheManager.setStoreByValue(true);
        return cacheManager;
    }
}

However, it does not worked serialization and deserialization a cache value :(
Is my configuration wrong ?

I've tried as follow, it work fine. I want to know best configuration for this case.

@EnableCaching
@Configuration
public class CacheConfig implements BeanClassLoaderAware { // Add

    ClassLoader classLoader;

    @Override
    public void setBeanClassLoader(ClassLoader classLoader) {
        this.classLoader = classLoader;
    }

    @Bean
    CacheManager cacheManager() {
        ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager("configs");
        cacheManager.setBeanClassLoader(classLoader); // Add
        cacheManager.setStoreByValue(true);
        return cacheManager;
    }

}

Affects: 4.3 RC2

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

The classloader callback interface hasn't been invoked yet so any attempt to actually enable the flag won't work. We should defer the creation of the caches once the bean is fully initialized or find another way to deal with this.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

We're recreating existing caches in setBeanClassLoaderAware now when in store-by-value mode.

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

2 participants