Hi Stuart,

On 22.01.21 08:26, Stuart Maclean wrote:
I have a cache region whose key type is say String and whose value type is some class C.  C is Serializable.

I use the cache, so objects of class C go into that region. The cache is backed by disk, so objects of class C end up in files.

C may then change, such that its serialVersionUID changes. If so, what I want to happen is that when I do a

I guess what you are looking for happens in e.g. org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCache.readElement(K)

In this method, the ClassNotFoundException from deserialization is wrapped into an IOException. This exception is then caught by org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCache.processGet(K)

In the catch clause, reset() is called, which clears the cache. So actually the behavior you are asking for actually should be there.

If you need more detailed control, you may provide your own org.apache.commons.jcs.engine.behavior.IElementSerializer and use the object validation features described in java.io.ObjectInputStream.registerValidation(ObjectInputValidation, int)

You will have to create the disk cache programmatically then, as the IElementSerializer cannot be set via configuration.

HTH
Bye, Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to