Skip to content

Commit 067f2ef

Browse files
author
Vladimir Kotal
committed
handle null revision string
1 parent b97330c commit 067f2ef

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/FileHistoryCache.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,14 @@ private String createFileMap(History history, HashMap<String, List<HistoryEntry>
438438
return latestRev;
439439
}
440440

441+
private static String getRevisionString(String revision) {
442+
if (revision == null) {
443+
return "end of history";
444+
} else {
445+
return "revision " + revision;
446+
}
447+
}
448+
441449
/**
442450
* Store history for the whole repository in directory hierarchy resembling
443451
* the original repository structure. History of individual files will be
@@ -475,21 +483,23 @@ public void store(History history, Repository repository, String tillRevision) t
475483

476484
Set<String> regularFiles = map.keySet().stream().
477485
filter(e -> !history.isRenamed(e)).collect(Collectors.toSet());
478-
createDirectoriesForFiles(regularFiles, repository, "regular files for history till " + tillRevision);
486+
createDirectoriesForFiles(regularFiles, repository, "regular files for history till " +
487+
getRevisionString(tillRevision));
479488

480489
/*
481490
* Now traverse the list of files from the hash map built above and for each file store its history
482491
* (saved in the value of the hash map entry for the file) in a file.
483492
* The renamed files will be handled separately.
484493
*/
485-
LOGGER.log(Level.FINE, "Storing history for {0} regular files in repository ''{1}'' till history {2}",
486-
new Object[]{regularFiles.size(), repository.getDirectoryName(), tillRevision});
494+
LOGGER.log(Level.FINE, "Storing history for {0} regular files in repository ''{1}'' till {2}",
495+
new Object[]{regularFiles.size(), repository.getDirectoryName(), getRevisionString(tillRevision)});
487496
final File root = env.getSourceRootFile();
488497

489498
final CountDownLatch latch = new CountDownLatch(regularFiles.size());
490499
AtomicInteger fileHistoryCount = new AtomicInteger();
491500
try (Progress progress = new Progress(LOGGER,
492-
String.format("history cache for regular files of %s till history %s", repository, tillRevision),
501+
String.format("history cache for regular files of %s till %s", repository,
502+
getRevisionString(tillRevision)),
493503
regularFiles.size())) {
494504
for (String file : regularFiles) {
495505
env.getIndexerParallelizer().getHistoryFileExecutor().submit(() -> {
@@ -540,16 +550,18 @@ public void storeRenamed(Set<String> renamedFiles, Repository repository, String
540550

541551
renamedFiles = renamedFiles.stream().filter(f -> new File(env.getSourceRootPath() + f).exists()).
542552
collect(Collectors.toSet());
543-
LOGGER.log(Level.FINE, "Storing history for {0} renamed files in repository ''{1}'' till history {2}",
544-
new Object[]{renamedFiles.size(), repository.getDirectoryName(), tillRevision});
553+
LOGGER.log(Level.FINE, "Storing history for {0} renamed files in repository ''{1}'' till {2}",
554+
new Object[]{renamedFiles.size(), repository.getDirectoryName(), getRevisionString(tillRevision)});
545555

546-
createDirectoriesForFiles(renamedFiles, repository, "renamed files for history till " + tillRevision);
556+
createDirectoriesForFiles(renamedFiles, repository, "renamed files for history " +
557+
getRevisionString(tillRevision));
547558

548559
final Repository repositoryF = repository;
549560
final CountDownLatch latch = new CountDownLatch(renamedFiles.size());
550561
AtomicInteger renamedFileHistoryCount = new AtomicInteger();
551562
try (Progress progress = new Progress(LOGGER,
552-
String.format("history cache for renamed files of %s till history %s", repository, tillRevision),
563+
String.format("history cache for renamed files of %s till %s", repository,
564+
getRevisionString(tillRevision)),
553565
renamedFiles.size())) {
554566
for (final String file : renamedFiles) {
555567
env.getIndexerParallelizer().getHistoryFileExecutor().submit(() -> {

0 commit comments

Comments
 (0)