@@ -78,8 +78,6 @@ class FileHistoryCache extends AbstractCache implements HistoryCache {
7878 private static final Logger LOGGER = LoggerFactory .getLogger (FileHistoryCache .class );
7979 private static final RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
8080
81- private final Object lock = new Object ();
82-
8381 private static final String HISTORY_CACHE_DIR_NAME = "historycache" ;
8482 private static final String LATEST_REV_FILE_NAME = "OpenGroklatestRev" ;
8583
@@ -350,31 +348,23 @@ private void storeFile(History histNew, File file, Repository repo, boolean merg
350348 }
351349 }
352350
353- // TODO: adjust the comment and revisit the locking - is it really needed ?
354- // We have a problem that multiple threads may access the cache layer
355- // at the same time. Since I would like to avoid read-locking, I just
356- // serialize the write access to the cache file. The generation of the
357- // cache file would most likely be executed during index generation, and
358- // that happens sequentially anyway....
359351 // Generate the file with a temporary name and move it into place when
360352 // done, so it is not necessary to protect the readers for partially updated
361- // files...
362- synchronized (lock ) {
363- if (assignTags ) {
364- // Store tags in separate file.
365- // Ideally that should be done using the cycle above to avoid dealing with complete History instance.
366- File outputTagsFile = getTagsFile (outputFile );
367- try {
368- writeTagsTo (outputTagsFile , histNew );
369- } catch (IOException ioe ) {
370- throw new HistoryException ("Failed to write tags" , ioe );
371- }
372-
373- safelyRename (outputTagsFile , getTagsFile (cacheFile ));
353+ // files.
354+ if (assignTags ) {
355+ // Store tags in separate file.
356+ // Ideally that should be done using the cycle above to avoid dealing with complete History instance.
357+ File outputTagsFile = getTagsFile (outputFile );
358+ try {
359+ writeTagsTo (outputTagsFile , histNew );
360+ } catch (IOException ioe ) {
361+ throw new HistoryException ("Failed to write tags" , ioe );
374362 }
375363
376- safelyRename (outputFile , cacheFile );
364+ safelyRename (outputTagsFile , getTagsFile ( cacheFile ) );
377365 }
366+
367+ safelyRename (outputFile , cacheFile );
378368 }
379369
380370 private void finishStore (Repository repository , String latestRev ) {
0 commit comments