Skip to content

Bypass JSR107 layer when creating cache cause it to be not found #2494

@henri-tremblay

Description

@henri-tremblay

If a cache is created directory on the wrapped Ehcache CacheManager, the JSR107 won' see it. See this code:

    @Test
    public void test() {
        CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
        org.ehcache.CacheManager ecm = cacheManager.unwrap(org.ehcache.CacheManager.class);
        ecm.createCache("foo", CacheConfigurationBuilder.newCacheConfigurationBuilder(Integer.class, String.class, ResourcePoolsBuilder.heap(1)));

        Cache<Integer, String> cache = cacheManager.getCache("foo", Integer.class, String.class);
        assertThat(cache).isNotNull(); // fails
    }

However, add a cacheManager.getCacheNames() before calling getCache repairs it since it causes a cache refresh.

I think it should work or at least be coherent.

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions