@@ -78,8 +78,6 @@ class FileHistoryCache extends AbstractCache implements HistoryCache {
78
78
private static final Logger LOGGER = LoggerFactory .getLogger (FileHistoryCache .class );
79
79
private static final RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
80
80
81
- private final Object lock = new Object ();
82
-
83
81
private static final String HISTORY_CACHE_DIR_NAME = "historycache" ;
84
82
private static final String LATEST_REV_FILE_NAME = "OpenGroklatestRev" ;
85
83
@@ -350,31 +348,23 @@ private void storeFile(History histNew, File file, Repository repo, boolean merg
350
348
}
351
349
}
352
350
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....
359
351
// Generate the file with a temporary name and move it into place when
360
352
// 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 );
374
362
}
375
363
376
- safelyRename (outputFile , cacheFile );
364
+ safelyRename (outputTagsFile , getTagsFile ( cacheFile ) );
377
365
}
366
+
367
+ safelyRename (outputFile , cacheFile );
378
368
}
379
369
380
370
private void finishStore (Repository repository , String latestRev ) {
0 commit comments