sgala 02/04/25 11:40:22 Modified: src/java/org/apache/jetspeed/cache/disk JetspeedDiskCache.java Log: This is a hack for the race condition we have been experiencing. I describe here what I know: JetspeedDiskCache.initEntries() ask for the URLManager service to register the urls it loads. This locks (or waits for) JetspeedURLManagerService.urls while holding a lock on JetspeedDiskCache.instances. Possibly somewhere else in early initialization (I cannot find it) some other thread has the lock on urls, and then tries to get a Cache Entry. If URLManager is not completely initialized when Cache starts running, the threads lock. Doing it this way, we don't get the lock on instances until URLManager is done. A proper solution would be to integrate the Cache with the URLManager, having all the cache accesses through the URLManager (intended since one year ago). Revision Changes Path 1.45 +15 -2 jakarta-jetspeed/src/java/org/apache/jetspeed/cache/disk/JetspeedDiskCache.java Index: JetspeedDiskCache.java =================================================================== RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/cache/disk/JetspeedDiskCache.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- JetspeedDiskCache.java 19 Apr 2002 16:22:34 -0000 1.44 +++ JetspeedDiskCache.java 25 Apr 2002 18:40:22 -0000 1.45 @@ -82,7 +82,7 @@ @see org.apache.jetspeed.daemon.impl.DiskCacheDaemon @author <A HREF="mailto:[EMAIL PROTECTED]">Kevin A. Burton</A> @author <a href="mailto:[EMAIL PROTECTED]">Santiago Gala</a> -@version $Id: JetspeedDiskCache.java,v 1.44 2002/04/19 16:22:34 taylor Exp $ +@version $Id: JetspeedDiskCache.java,v 1.45 2002/04/25 18:40:22 sgala Exp $ */ public class JetspeedDiskCache implements DiskCache { @@ -91,7 +91,7 @@ The default cache folder */ public static String DEFAULT_CACHE_DIRECTORY = - JetspeedResources.getString( JetspeedResources.CACHE_DIRECTORY_KEY ); + JetspeedResources.getString( JetspeedResources.CACHE_DIRECTORY_KEY, "WEB-INF/cache" ); /** Stores instances of JetspeedDiskCaches @@ -125,6 +125,19 @@ private void initEntries() { Log.info("Disk Cache init Entries..."); + //HACK: we need the URLManager started now to avoid locks... + //init() acts as a barrier, making our thread wait until + //URLManager is done initialization. + //This is the long time sought sporadic race condition/lock :-) + //To whomever rewrite this code: please change API so the cache is initialized + //through the URLManager service *after* the Manager is initialized, and possibly + //accessed through URLManager.getReader( url ) or something similar. + try { + org.apache.turbine.services.TurbineServices + .getInstance() + .getService( org.apache.jetspeed.services.urlmanager.URLManagerService.SERVICE_NAME ).init(); + } catch (Throwable t) {} + File temp = new File( directory ); String files[] = temp.list();
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>