I am getting strange Cache class cast exceptions when running my usual GitHub Actions pipeline where I start Confluence dockerized as service container with postgreSQL 17.
Locally when doing the exact same steps with the exact same docker containers, I cannot reproduce the error.
I am using Confluence 10.2.1 and this happened with 10.2.0 and all EAPs too. I thought maybe the error would disappear in later minor versions.
I get these errors on my cache Object:
java.lang.ClassCastException: class foo.bar.mymacro.cache.MyCacheObj cannot be cast to class foo.bar.mymacro.cache.MyCacheObj
(foo.bar.mymacro.cache.MyCacheObj is in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader
@4a8c25b6; foo.bar.mymacro.cache.MyCacheObj is in unnamed module of loader
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @50c5aea4)
I am following these rules for years and until 10.2 all has worked without any problems:
What could be the cause?
My Impl:
myLoader = new CacheLoader<String, MyCacheObj>() {
public MyCacheObj load(String key) {
// do stuff
return new MyCacheObj();
}
};
this.cache = cacheManager.getCache(MACRO_CACHE_KEY, myLoader, new CacheSettingsBuilder()
.maxEntries(100) // 100 * 2MB = 200MB max
.replicateAsynchronously()
.local()
.expireAfterWrite(1, TimeUnit.DAYS)
.build());
// ...
MyCacheObj cacheObj = this.cache.get(cacheKey.getCacheKey());
And the MyCacheObj is simply a mojo which is serializable with hashCode and equals and getter/setters.
I can reproduce it now: It happens starting Confluence 10.2+ when you install the app, uninstall it and reinstall it again. Then these errors occur.