[
https://issues.jboss.org/browse/ISPN-4563?page=com.atlassian.jira.plugin....
]
Sebastian Łaskawiec commented on ISPN-4563:
-------------------------------------------
The root cause of this bug is in JCacheManager.java:
{code}
public <K, V, C extends Configuration<K, V>> Cache<K, V> createCache(
String cacheName, C configuration) {
...
// re-register attempt with different configuration
if (cache.getConfiguration(Configuration.class).equals(configuration)) {
throw log.cacheAlreadyRegistered(cacheName,
cache.getConfiguration(Configuration.class), configuration);
}
{code}
Above code should be replaced by:
{code}
public <K, V, C extends Configuration<K, V>> Cache<K, V> createCache(
String cacheName, C configuration) {
...
// re-register attempt with different configuration
// Note that configuration should not be equal...
if (!cache.getConfiguration(Configuration.class).equals(configuration)) {
throw log.cacheAlreadyRegistered(cacheName,
cache.getConfiguration(Configuration.class), configuration);
}
{code}
However with this change, JCache testing suite
(org.jsr107.tck.CacheManagerTest#getOrCreateCache_Same()) blows out:
{code}
@Test
public void createCache_Same() {
String name = "c1";
CacheManager cacheManager = getCacheManager();
try {
cacheManager.createCache(name, new MutableConfiguration());
Cache cache1 = cacheManager.getCache(name);
cacheManager.createCache(name, new MutableConfiguration());
Cache cache2 = cacheManager.getCache(name);
fail();
} catch (CacheException exception) {
//expected
}
}
{code}
This happens because configurations created by {{new MutableConfiguration()}} are
logically equal ({{config1.equals(config2)}}).
There are two solutions here:
* Compare configurations using {{==}} rather then {{equals}} method (I don't think we
should follow this direction).
* There is a mistake in JCache testing suite and it should be fixed in the upstream.
Race condition in JCache creation for interceptors
--------------------------------------------------
Key: ISPN-4563
URL:
https://issues.jboss.org/browse/ISPN-4563
Project: Infinispan
Issue Type: Bug
Components: CDI Integration
Affects Versions: 6.0.2.Final
Reporter: Elias Ross
Assignee: Sebastian Łaskawiec
Fix For: 7.0.0.Final
Intercepted methods, annotated like @CacheResult, if called from multiple threads, can
attempt to create multiple caches.
Work-around is to create the cache in a @PostContruct block.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)