Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
2 Major
-
Resolution: Fixed
-
Affects Version/s: 2.4.6
-
Fix Version/s: 2.4.7
-
Component/s: ehcache-core
-
Labels:None
-
Terracotta Target:3.5.4/Ehcache 2.4.7
-
Fixed In Revision:ehcache-core-2.4.x:4974 ehcache-core-2.4.x:4975 trunk:4976
Description
DiskOverflowStorageFactory.getDataFile creates the temp directory if it does not yet exist:
if (!diskDir.exists() && !diskDir.mkdirs()) { throw new CacheException("Could not create cache directory \"" + diskDir.getAbsolutePath() + "\"."); }
Unfortunately, there is a race condition in this code fragment that causes trouble if the directory is created between the diskDir.exists() and diskDir.mkdirs() calls (diskDir.mkdirs() will return false if the directory already exists).
Patch proposal:
if (!diskDir.exists() && !diskDir.mkdirs() && !diskDir.exists()) { throw new CacheException("Could not create cache directory \"" + diskDir.getAbsolutePath() + "\"."); }