Permalink
Browse files

ISPN-2639 Keep CDI module using JCache 0.4 and fix classloader weak ref

* Keep JSR-107 annotations using 0.4 until issue has been solved.
This will be addressed as part of ISPN-2855.
* Fix issues with classloader weak references.
* Implement missing methods in listener event adapter implementations
in the CDI module.
  • Loading branch information...
1 parent 088eeba commit 508af2416da6693d39c5941dd097d95a85b8293f @galderz galderz committed with maniksurtani Feb 27, 2013
View
@@ -54,6 +54,16 @@
</developer>
</developers>
+ <properties>
+ <!-- Version 0.6 version has this issue:
+ https://github.com/jsr107/jsr107spec/pull/59
+
+ Upgrade to 0.6 once that issue has been fixed
+ See https://issues.jboss.org/browse/ISPN-2855
+ -->
+ <version.javax.cache>0.4</version.javax.cache>
+ </properties>
+
<dependencies>
<dependency>
<groupId>javax.cache</groupId>
@@ -68,6 +68,12 @@ public boolean isPre() {
public Cache<Object, Object> getCache() {
return null;
}
+
+ @Override
+ public Object getValue() {
+ return null;
+ }
+
};
@SuppressWarnings("serial")
@@ -74,6 +74,11 @@ public Object getValue() {
return null;
}
+ @Override
+ public Object getOldValue() {
+ return null;
+ }
+
};
@SuppressWarnings("serial")
@@ -53,6 +53,16 @@
</developer>
</developers>
+ <properties>
+ <!-- Version 0.6 version has this issue:
+ https://github.com/jsr107/jsr107spec/pull/59
+
+ Upgrade to 0.6 once that issue has been fixed
+ See https://issues.jboss.org/browse/ISPN-2855
+ -->
+ <version.javax.cache>0.4</version.javax.cache>
+ </properties>
+
<dependencies>
<!-- JCache annotations implementation -->
<dependency>
@@ -70,5 +70,4 @@ public int getTopologyId() {
public void setTopologyId(int topologyId) {
this.topologyId = topologyId;
}
-
}
@@ -112,5 +112,4 @@ public void setRemotelyFetchedValue(InternalCacheEntry remotelyFetchedValue) {
public InternalCacheEntry getRemotelyFetchedValue() {
return remotelyFetchedValue;
}
-
}
@@ -96,7 +96,6 @@ public Object perform(InvocationContext ctx) throws Throwable {
}
final Object removedValue = e.getValue();
-
notify(ctx, removedValue, true);
e.setRemoved(true);
@@ -191,7 +191,7 @@ public boolean equals(Object o) {
Configuration that = (Configuration) o;
- if (classLoader != null ? !classLoader.equals(that.classLoader) : that.classLoader != null)
+ if (classLoader != null && classLoader.get() != null && that.classLoader != null ? !classLoader.get().equals(that.classLoader.get()) : that.classLoader != null && that.classLoader.get() != null)
return false;
if (clusteringConfiguration != null ? !clusteringConfiguration.equals(that.clusteringConfiguration) : that.clusteringConfiguration != null)
return false;
@@ -233,7 +233,7 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
- int result = classLoader != null ? classLoader.hashCode() : 0;
+ int result = classLoader != null && classLoader.get() != null ? classLoader.get().hashCode() : 0;
result = 31 * result + (clusteringConfiguration != null ? clusteringConfiguration.hashCode() : 0);
result = 31 * result + (customInterceptorsConfiguration != null ? customInterceptorsConfiguration.hashCode() : 0);
result = 31 * result + (dataContainerConfiguration != null ? dataContainerConfiguration.hashCode() : 0);
@@ -76,7 +76,7 @@ public ConfigurationBuilder classLoader(ClassLoader cl) {
}
ClassLoader classLoader() {
- return classLoader.get();
+ return classLoader != null ? classLoader.get() : null;
}
@Override
@@ -231,12 +231,6 @@
* For example, if this flag is passed as a result of a {@link Cache#get(Object)}
* call, no callbacks will be made on listeners annotated with
* {@link org.infinispan.notifications.cachelistener.annotation.CacheEntryVisited}.
- *
- * A typical use case of this flag is when trying to comply with
- * specifications such as JSR-107, which mandate that
- * {@link Cache#containsKey(Object)}} calls do not fire entry visited
- * notifications, while maintaining the same behaviour that Infinispan
- * has done in the past.
*/
SKIP_LISTENER_NOTIFICATION,
@@ -136,7 +136,7 @@ public AbstractInvocationContext clone() {
@Override
public ClassLoader getClassLoader() {
- return classLoader.get();
+ return classLoader != null ? classLoader.get() : null;
}
@Override
@@ -206,7 +206,7 @@ public void invoke(final Object event) {
@Override
public void run() {
ClassLoader contextClassLoader = null;
- if (classLoader != null) {
+ if (classLoader != null && classLoader.get() != null) {
contextClassLoader = setContextClassLoader(classLoader.get());
}
try {
@@ -227,7 +227,7 @@ public void run() {
getLog().unableToInvokeListenerMethod(method, target, exception);
removeListener(target);
} finally {
- if (classLoader != null) {
+ if (classLoader != null && classLoader.get() != null) {
setContextClassLoader(contextClassLoader);
}
}
@@ -80,9 +80,16 @@ public JCache(AdvancedCache<K, V> cache, JCacheManager cacheManager,
this.cache = cache;
this.ignoreReturnValuesCache = cache.withFlags(Flag.IGNORE_RETURN_VALUES);
this.skipCacheLoadCache = cache.withFlags(Flag.SKIP_CACHE_LOAD);
+
+ // Typical use cases of the SKIP_LISTENER_NOTIFICATION is when trying
+ // to comply with specifications such as JSR-107, which mandate that
+ // {@link Cache#containsKey(Object)}} calls do not fire entry visited
+ // notifications, while maintaining the same behaviour that Infinispan
+ // has done in the past.
this.containsKeyCache = skipCacheLoadCache
.withFlags(Flag.SKIP_LISTENER_NOTIFICATION);
this.skipListenerCache = cache.withFlags(Flag.SKIP_LISTENER_NOTIFICATION);
+
this.cacheManager = cacheManager;
// a configuration copy as required by the spec
this.configuration = new SimpleConfiguration<K, V>(c);

0 comments on commit 508af24

Please sign in to comment.