AuthenticationCache cache not serialized

Description

2012-02-28 16:45:13,789 ERROR org.sakaiproject.user.api.AuthenticationManager.data net.sf.ehcache.store.disk.DiskStorageFactory - Disk Write of admin failed:
java.io.NotSerializableException: org.sakaiproject.user.impl.AuthenticationCache$AuthenticationRecord
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:422)
at net.sf.ehcache.Element.writeObject(Element.java:797)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:940)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1469)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97)
at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:413)
at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:392)
at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:493)
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1154)
at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1138)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Environment

None

Test Plan

None

Activity

Show:

Sam Ottenhoff September 21, 2012 at 1:40 PM

1.3.x: r113397

Hudson CI Server February 29, 2012 at 9:16 AM

Integrated in kernel-trunk #462 (See http://builds.sakaiproject.org:8080/job/kernel-trunk/462/)

Result = SUCCESS

Noah Botimer February 29, 2012 at 5:46 AM

Please review r105277. It is the simplest (and, I think, most correct) approach: adding Serializable to these very basic classes. The total payload is a byte array for the hashed password and string versions of the user ID and EID, so I cannot see any hazard. The error no longer occurs on startup.

Matthew's concerns seem important and should be addressed. It looks like the behavior is not caused by the upgrade, though, so should be tracked separately.

Matthew Jones February 28, 2012 at 11:49 AM

I think the bigger problem with this (besides that you need to change your cache if you WANT to overflowToDisk) is that some of the caches appear to be getting the fail safe settings rather than the defined settings in ehcache.xml. This probably shouldn't even overflowToDisk at all, not for security but for unexpected performance reasons. This one only now has 250 maxEntriesLocalHeap verses 10,000 before!

Though I'm sure disk is better than database, in most cases you'd just want to increase the max size)

http://www.ehcache.org/documentation/user-guide/configuration#ehcache-failsafexml

(2.9 & trunk)
[ name = org.sakaiproject.user.api.AuthenticationManager status = STATUS_ALIVE eternal = false overflowToDisk = true maxEntriesLocalHeap = 250 maxEntriesLocalDisk = 10000000 memoryStoreEvictionPolicy = LRU timeToLiveSeconds = 120 timeToIdleSeconds = 120 diskPersistent = false diskExpiryThreadIntervalSeconds = 120 cacheEventListeners: net.sf.ehcache.statistics.LiveCacheStatisticsWrapper hitCount = 0 memoryStoreHitCount = 0 diskStoreHitCount = 0 missCountNotFound = 3 missCountExpired = 1 maxBytesLocalHeap = 0 overflowToOffHeap = false maxBytesLocalOffHeap = 0 maxBytesLocalDisk = 0 pinned = false ]

(2.8)
[ name = org.sakaiproject.user.api.AuthenticationManager status = STATUS_ALIVE eternal = false overflowToDisk = true maxElementsInMemory = 10000 maxElementsOnDisk = 10000000 memoryStoreEvictionPolicy = LRU timeToLiveSeconds = 120 timeToIdleSeconds = 120 diskPersistent = false diskExpiryThreadIntervalSeconds = 120 cacheEventListeners: hitCount = 1234 memoryStoreHitCount = 1234 diskStoreHitCount = 0 missCountNotFound = 295 missCountExpired = 178 ]

I'm not sure why some are getting the settings in here and others aren't yet though. It seems like all of these should be adjusted based on some production experience.

Matthew Jones February 28, 2012 at 10:55 AM

The AuthenticationCache only stores the password digest, not the actual passwords, so it should be fine whatever is done with this.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created February 28, 2012 at 7:05 AM
Updated April 25, 2018 at 3:34 PM
Resolved February 29, 2012 at 5:46 AM