Opened 7 years ago

Closed 7 years ago

#2074 closed enhancement (fixed)

Support for plug-ins to save custom information in the static cache

Reported by: Nicklas Nordborg Owned by: everyone
Priority: major Milestone: BASE 3.11
Component: core Version:
Keywords: Cc:

Description

The static cache can store any serializable object by calling the StaticCache.store() method. A plug-in may call this method directly (or indirectly by the Response.setPause() method; see #2072) without any problem.

However, when trying to read the information again the result is an exception:

java.io.IOException: java.lang.ClassNotFoundException: net.sf.basedb.relax.plugins.ReleaseImporterPlugin$Stats
	at net.sf.basedb.util.StaticCache.load(StaticCache.java:425)
	at net.sf.basedb.core.Job.loadState(Job.java:1435)
	at net.sf.basedb.core.PluginRequest.<init>(PluginRequest.java:85)
	at net.sf.basedb.core.PluginExecutionRequest.<init>(PluginExecutionRequest.java:74)
	at net.sf.basedb.core.Job.execute(Job.java:1561)
	at net.sf.basedb.core.Job.execute(Job.java:1512)
	at net.sf.basedb.core.Job.execute(Job.java:1503)
	at net.sf.basedb.core.InternalJobQueue$JobRunner.run(InternalJobQueue.java:560)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: net.sf.basedb.relax.plugins.ReleaseImporterPlugin$Stats
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Unknown Source)
	at java.io.ObjectInputStream.resolveClass(Unknown Source)
	at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
	at java.io.ObjectInputStream.readClassDesc(Unknown Source)
	at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
	at java.io.ObjectInputStream.readObject0(Unknown Source)
	at java.io.ObjectInputStream.readObject(Unknown Source)
	at net.sf.basedb.util.StaticCache.load(StaticCache.java:421)
	... 8 more

This happens because the data to load belongs to a plug-in and the static cache has no explicit knowledge of which correct class loader to use for finding the class definition.

The StaticCache API should be extended with read/load methods that also take a ClassLoader parameter.

Change History (1)

comment:1 by Nicklas Nordborg, 7 years ago

Resolution: fixed
Status: newclosed

(In [7324]) Fixes #2074: Support for plug-ins to save custom information in the static cache

The functionality could be implemented by subclassing the ObjectInputStream and implementing the resolveClass() method.

Note: See TracTickets for help on using tickets.