Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
jcs-2.2.1
-
None
Description
How to repro
- Configure a composite cache with an indexed disk cache as the auxiliary.
- Now in one single JVM (e.g. in a single main method), do the following:
- Create the cache, possibly putting something in.
- Note that the disk cache files are created
- JCS.shutdown()
- Remove the files of the disk cache
- Create the cache again.
- Put stuff in
What to observe
The disk cache files are not created again.
In fact, the logging for the first run shows output like this:
INFORMATION: Constructed cache with name [CACHE] and cache attributes [ useLateral = true, useRemote = true, useDisk = true, maxObjs = 1, maxSpoolPerRun = 500, diskUsagePattern = SWAP, spoolChunkSize = 2 ] Jun 25, 2019 4:19:58 PM org.apache.commons.jcs.auxiliary.AuxiliaryCacheConfigurator parseCacheEventLogger INFORMATION: No cache event logger defined for auxiliary [jcs.auxiliary.DISK] Jun 25, 2019 4:19:58 PM org.apache.commons.jcs.auxiliary.AuxiliaryCacheConfigurator parseElementSerializer INFORMATION: Using standard serializer [org.apache.commons.jcs.utils.serialization.StandardSerializer@1ddf84b8] for auxiliary [jcs.auxiliary.DISK] [...] Jun 25, 2019 4:19:59 PM org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCache <init> INFORMATION: Region [CACHE] Indexed Disk Cache is alive.
The logging of the second run shows output like this:
INFORMATION: Constructed cache with name [CACHE] and cache attributes [ useLateral = true, useRemote = true, useDisk = true, maxObjs = 1, maxSpoolPerRun = 500, diskUsagePattern = SWAP, spoolChunkSize = 2 ]
Please note that in the latter case the lines about initializing the IndexedDiskCache are missing, event though the configuration states that a disk cache is to be used.
What is expected
In the second run, the disk cache files should be created again as a consequence of creating new auxiliary caches. It is expected that shutting down the JCS will shut down every subsystem.
Relevance
The issue comes up when restarting a web API system including deleting the contents of the temporary directory.
Note
The bug may be fixed by setting the instance field in CompositeCacheManager to null at some point during the shutdown process. Maybe in CompositeCacheManager.shutdown().