Skip to content

Commit 63bb2fd

Browse files
authored
Merge branch 'apache:main' into pr-12543
2 parents a9cc2fc + f2287e7 commit 63bb2fd

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.apache.lucene.store.Directory;
4747
import org.apache.lucene.store.FSDirectory;
4848
import org.apache.lucene.util.IOUtils;
49+
import org.apache.lucene.util.SuppressForbidden;
4950

5051
/**
5152
* Data maintained by a performance test run.
@@ -204,7 +205,7 @@ public void reinit(boolean eraseIndex) throws Exception {
204205
resetInputs();
205206

206207
// release unused stuff
207-
System.runFinalization();
208+
runFinalization();
208209
System.gc();
209210

210211
// Re-init clock
@@ -482,4 +483,10 @@ public synchronized QueryMaker getQueryMaker(ReadTask readTask) {
482483
public Map<String, AnalyzerFactory> getAnalyzerFactories() {
483484
return analyzerFactories;
484485
}
486+
487+
@SuppressWarnings("removal")
488+
@SuppressForbidden(reason = "requires to run finalization")
489+
private static void runFinalization() {
490+
System.runFinalization();
491+
}
485492
}

lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,13 @@ public void testCorruptFirstCommit() throws Exception {
23722372

23732373
public void testHasUncommittedChanges() throws IOException {
23742374
Directory dir = newDirectory();
2375-
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
2375+
IndexWriter writer =
2376+
new IndexWriter(
2377+
dir,
2378+
newIndexWriterConfig(new MockAnalyzer(random()))
2379+
// Use a serial merge scheduler to avoid race conditions when checking for
2380+
// hasPendingMerges()
2381+
.setMergeScheduler(new SerialMergeScheduler()));
23762382
assertTrue(
23772383
writer.hasUncommittedChanges()); // this will be true because a commit will create an empty
23782384
// index

lucene/core/src/test/org/apache/lucene/util/TestWeakIdentityMap.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void testSimpleHashMap() {
119119
int size = map.size();
120120
for (int i = 0; size > 0 && i < 10; i++)
121121
try {
122-
System.runFinalization();
122+
runFinalization();
123123
System.gc();
124124
int newSize = map.size();
125125
assertTrue("previousSize(" + size + ")>=newSize(" + newSize + ")", size >= newSize);
@@ -232,7 +232,7 @@ public void run() {
232232
int size = map.size();
233233
for (int i = 0; size > 0 && i < 10; i++)
234234
try {
235-
System.runFinalization();
235+
runFinalization();
236236
System.gc();
237237
int newSize = map.size();
238238
assertTrue("previousSize(" + size + ")>=newSize(" + newSize + ")", size >= newSize);
@@ -252,4 +252,10 @@ public void run() {
252252
InterruptedException ie) {
253253
}
254254
}
255+
256+
@SuppressWarnings("removal")
257+
@SuppressForbidden(reason = "requires to run finalization")
258+
private static void runFinalization() {
259+
System.runFinalization();
260+
}
255261
}

0 commit comments

Comments
 (0)