I'm using Java7 and I'm configuring Apaches Ignite (version 2.7.5) where the servers/clients are up and running. However, clients are unable to retrieve Guavas LoadingCache variable from the object (however ConcurrentHashMap is retrieved without issues). It seems that somehow on Ignites proxy calls the object is not serialized/deserialized correctly and I'm having trouble as Guavas docs says that LoadingCache/Cache implement Serializable.
In the following sample, MyContainer class and _foo1 are ok and were correctly serialized and deserialized but _foo (LoadingCache) was not.
public class MyContainer {
private final ConcurrentHashMap<Object, Object> _foo1 = new ConcurrentHashMap<>();
private final LoadingCache<Object, Test> _foo = CacheBuilder.newBuilder().weakValues()
.build(new CacheLoader<Object, Test>() {
@Override public Test load(Object key) throws Exception {
return new Test(key);
}});
}
Please let me know if you need more details and any help is greatly appreciated. Best Regards, Hélder
UPDATE
Hello everyone, with Denis response I did more digging and found some mentions about cfg.setMarshaller(new OptimizedMarshaller().setRequireSerializable(false));
and it worked. However, setMarshaller is deprecated and I'm not sure about this approach implications mainly at performance level.
Any read/explanation on what was the big deal behind the deprecation of this method?
Best Regards, Hélder
The CacheBuilder
constructs an instance of LocalCache.LocalLoadingCache
. It has a writeReplace
method that messes up the serialization.
This issue has been fixed in Ignite 2.3: https://issues.apache.org/jira/browse/IGNITE-6485
Which version of Ignite do you use? I would recommend upgrading to a fresh version of Ignite and switching to Java 8 or 11, since Java 7 is not supported by Ignite anymore.