You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by Al Forbes <fo...@googlemail.com> on 2008/12/18 10:22:37 UTC

Serialization issues

Hi,

When cache gets a serialization error it directly tries to switch to the
backup remote cache. A serialization error is not an indication that the
cache is not functioning correctly - just that the data is invalid.


Dec 18 09:09:17 eul0300354 [2008-12-18 09:09:16,477]
org.apache.jcs.auxiliary.remote.RemoteCache ERROR  - *Disabling remote cache
due to error:* Failed to get [testKey] from [fareCache]
Dec 18 09:09:17 eul0300354 java.io.InvalidClassException:
com.ee.ibe.buslogic.PriceLine; local class incompatible: stream classdesc
serialVersionUID = 1, local class serialVersionUID = 2
Dec 18 09:09:17 eul0300354     at
java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
Dec 18 09:09:17 eul0300354     at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
Dec 18 09:09:17 eul0300354     at
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
Dec 18 09:09:17 eul0300354     at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
Dec 18 09:09:18 eul0300354     at
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)

In the method
   protected void handleException( Exception ex, String msg, String
eventName )
could we have the following change? There may be an alternative to catching
serialization errors earlier, but this seems to be the simplest change. See
what you think.


Index: src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java
===================================================================
--- src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java    (revision
727672)
+++ src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java    (working
copy)
@@ -124,6 +124,17 @@
         logError( cacheName, "", message );
         log.error( message, ex );

+        /** For serialization errors, there is no problem with the remote
+         * cache, so we don't do the failover.
+         * Errors are usually of the form:
+         * local class incompatible: stream classdesc serialVersionUID = 1,

+         *                           local class serialVersionUID = 2
+         */
+        if ( ex instanceof java.io.InvalidClassException )
+        {
+            return;
+        }
+
         // we should not switch if the existing is a zombie.
         if ( getRemoteCacheService() == null || !( getRemoteCacheService()
instanceof ZombieRemoteCacheService ) )
         {



Regards,
Al