EHC ❯ DiskStore loadElementFromDiskElement bug
-
Bug
-
Status: Closed
-
-
Resolution: Fixed
-
-
-
drb
-
Reporter: sourceforgetracker
-
September 21, 2009
-
0
-
Watchers: 0
-
September 22, 2009
-
September 22, 2009
Description
Hi.
The overriden method protected Class resolveClass(ObjectStreamClass clazz) throws ClassNotFoundException { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); return Class.forName(clazz.getName(), false, classLoader); }
in the loadElementFromDiskElement method throws an Exception when the clazz is a primitive type (e.g. double). This happens when we put in the cache an object which contains such primitive types and the cache overflows to the disk. Also, why it was necessary to override the default behaviour of this method, since it already handles the primitive types as well?
Regards.
Sourceforge Ticket ID: 1517565 - Opened By: nobody - 5 Jul 2006 14:58 UTC
Comments
Sourceforge Tracker 2009-09-21
Fiona OShea 2009-09-22
Re-opening so that I can properly close out these issues and have correct Resolution status in Jira
Logged In: YES user_id=693320
Hi
Following is a test where I try to reproduce the bug:
public class Primitive implements Serializable { public int integerPrimitive; public long longPrimitive; public byte bytePrimitive; public char charPrimitive; public boolean booleanPrimitive;
The test passes with no issue. Can you please provide a test case for the bug you are experiencing.
As to why the change was made, it was because of a bug reported when ehcache is used with Tomcat. See http://sourceforge.net/tracker/index.php? func=detail&aid=1324221&group_id=93232&atid=603559
I have changed it to:
final ObjectInputStream objstr = new ObjectInputStream(instr) { protected Class resolveClass(ObjectStreamClass clazz) throws ClassNotFoundException, IOException { try { ClassLoader classLoader = Thread.currentThread ().getContextClassLoader(); return Class.forName(clazz.getName(), false, classLoader); } catch (ClassNotFoundException e) { return super.resolveClass(clazz); } } };
Hopefully that will work for you. I can see from the standard implementation that it resolves primitives but I am not sure how to reproduce your issue.
Greg Comment by: gregluck - 16 Jul 2006 07:18 UTC