Skip to content

Commit b29f860

Browse files
author
Vladimir Kotal
committed
List.copyOf() redux
1 parent 928945a commit b29f860

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private void reset() {
6161

6262
/**
6363
* @param sinceRevision start revision ID
64-
* @return list of revision IDs denoting the intervals
64+
* @return immutable list of revision IDs denoting the intervals
6565
* @throws HistoryException if there is problem traversing the changesets in the repository
6666
*/
6767
public synchronized List<String> getBoundaryChangesetIDs(String sinceRevision) throws HistoryException {
@@ -75,14 +75,11 @@ public synchronized List<String> getBoundaryChangesetIDs(String sinceRevision) t
7575
// The changesets need to go from oldest to newest.
7676
Collections.reverse(result);
7777

78-
// Add null to finish the last step in Repository#createCache().
79-
result.add(null);
80-
8178
stat.report(LOGGER, Level.FINE,
8279
String.format("done getting boundary changesets for ''%s'' (%d entries)",
8380
repository.getDirectoryName(), result.size()));
8481

85-
return result;
82+
return List.copyOf(result);
8683
}
8784

8885
private void visit(String id) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.opengrok.indexer.util.Statistics;
2727

2828
import java.io.File;
29+
import java.util.ArrayList;
2930
import java.util.List;
3031
import java.util.function.Consumer;
3132
import java.util.logging.Level;
@@ -73,7 +74,8 @@ protected void doCreateCache(HistoryCache cache, String sinceRevision, File dire
7374
// (which can be sizeable, at least for the initial indexing, esp. if merge changeset support is enabled),
7475
// by splitting the work into multiple chunks.
7576
BoundaryChangesets boundaryChangesets = new BoundaryChangesets(this);
76-
List<String> boundaryChangesetList = boundaryChangesets.getBoundaryChangesetIDs(sinceRevision);
77+
List<String> boundaryChangesetList = new ArrayList<>(boundaryChangesets.getBoundaryChangesetIDs(sinceRevision));
78+
boundaryChangesetList.add(null); // to finish the last step in the cycle below
7779
LOGGER.log(Level.FINE, "boundary changesets: {0}", boundaryChangesetList);
7880
int cnt = 0;
7981
for (String tillRevision: boundaryChangesetList) {

opengrok-indexer/src/test/java/org/opengrok/indexer/history/BoundaryChangesetsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ private static Stream<ImmutableTriple<Integer, String, List<String>>> provideMap
9595
// Cannot use List.of() because of the null element.
9696
List<String> expectedChangesets2 = Arrays.asList("8482156421620efbb44a7b6f0eb19d1f191163c7",
9797
"ce4c98ec1d22473d4aa799c046c2a90ae05832f1",
98-
"1086eaf5bca6d5a056097aa76017a8ab0eade20f", null);
98+
"1086eaf5bca6d5a056097aa76017a8ab0eade20f");
9999

100-
List<String> expectedChangesets4 = Arrays.asList("ce4c98ec1d22473d4aa799c046c2a90ae05832f1", null);
100+
List<String> expectedChangesets4 = Arrays.asList("ce4c98ec1d22473d4aa799c046c2a90ae05832f1");
101101

102102
List<String> expectedChangesets2Middle = Arrays.asList("ce4c98ec1d22473d4aa799c046c2a90ae05832f1",
103-
"1086eaf5bca6d5a056097aa76017a8ab0eade20f", null);
103+
"1086eaf5bca6d5a056097aa76017a8ab0eade20f");
104104

105105
return Stream.of(ImmutableTriple.of(2, null, expectedChangesets2),
106106
ImmutableTriple.of(4, null, expectedChangesets4),

0 commit comments

Comments
 (0)