Skip to content

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

@spring-projects-issues

Description

@spring-projects-issues

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:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions