Skip to content

Commit 42685cc

Browse files
committed
Remove unneeded else
1 parent dd1a7e4 commit 42685cc

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,37 +2277,21 @@ public void testCommitWithOpenView() throws IOException {
22772277
for (int i = 0; i < operations; i++) {
22782278
translog.add(new Translog.NoOp(seqNo++, 0, "test"));
22792279
if (rarely()) {
2280-
if (randomBoolean()) {
2281-
try (Translog.View ignored = translog.newView()) {
2282-
final long viewGeneration = lastCommittedGeneration;
2283-
translog.prepareCommit();
2284-
final long committedGeneration = randomIntBetween(
2285-
Math.max(1, Math.toIntExact(lastCommittedGeneration)),
2286-
Math.toIntExact(translog.currentFileGeneration()));
2287-
translog.commit(committedGeneration);
2288-
lastCommittedGeneration = committedGeneration;
2289-
// with an open view, committing should preserve generations back to the last committed generation
2290-
for (long g = 1; g < Math.min(lastCommittedGeneration, viewGeneration); g++) {
2291-
assertFileDeleted(translog, g);
2292-
}
2293-
// the view generation could be -1 if no commit has been performed
2294-
final long max = Math.max(1, Math.min(lastCommittedGeneration, viewGeneration));
2295-
for (long g = max; g < translog.currentFileGeneration(); g++) {
2296-
assertFileIsPresent(translog, g);
2297-
}
2298-
}
2299-
} else {
2300-
final long generation = translog.currentFileGeneration();
2280+
try (Translog.View ignored = translog.newView()) {
2281+
final long viewGeneration = lastCommittedGeneration;
23012282
translog.prepareCommit();
23022283
final long committedGeneration = randomIntBetween(
23032284
Math.max(1, Math.toIntExact(lastCommittedGeneration)),
2304-
Math.toIntExact(generation));
2285+
Math.toIntExact(translog.currentFileGeneration()));
23052286
translog.commit(committedGeneration);
23062287
lastCommittedGeneration = committedGeneration;
2307-
for (long g = 1; g < lastCommittedGeneration; g++) {
2288+
// with an open view, committing should preserve generations back to the last committed generation
2289+
for (long g = 1; g < Math.min(lastCommittedGeneration, viewGeneration); g++) {
23082290
assertFileDeleted(translog, g);
23092291
}
2310-
for (long g = lastCommittedGeneration; g < translog.currentFileGeneration(); g++) {
2292+
// the view generation could be -1 if no commit has been performed
2293+
final long max = Math.max(1, Math.min(lastCommittedGeneration, viewGeneration));
2294+
for (long g = max; g < translog.currentFileGeneration(); g++) {
23112295
assertFileIsPresent(translog, g);
23122296
}
23132297
}

0 commit comments

Comments
 (0)