Skip to content

Commit cb16075

Browse files
authored
Replacing unused variable suppress warning with _ (Part 1/5) (#15102)
--------- Signed-off-by: Ankit Jain <[email protected]>
1 parent b1c1770 commit cb16075

File tree

53 files changed

+117
-334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+117
-334
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ private void truncateOneFile(Directory dir, String victim) throws IOException {
144144
// In some rare cases, the codec footer would still appear as correct even though the
145145
// file has been truncated. We just skip the test is this rare case.
146146
return;
147-
} catch (
148-
@SuppressWarnings("unused")
149-
CorruptIndexException e) {
147+
} catch (CorruptIndexException _) {
150148
// expected
151149
}
152150
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,7 @@ public void _run() throws Throwable {
459459
try {
460460
termsEnum.seekExact(idx);
461461
success = true;
462-
} catch (
463-
@SuppressWarnings("unused")
464-
UnsupportedOperationException uoe) {
462+
} catch (UnsupportedOperationException _) {
465463
// ok -- skip it
466464
}
467465
if (success) {
@@ -513,9 +511,7 @@ public void _run() throws Throwable {
513511
termsEnum.seekExact(i);
514512
assertEquals(field.terms[i].docs.length, termsEnum.docFreq());
515513
assertTrue(termsEnum.term().bytesEquals(new BytesRef(field.terms[i].text2)));
516-
} catch (
517-
@SuppressWarnings("unused")
518-
UnsupportedOperationException uoe) {
514+
} catch (UnsupportedOperationException _) {
519515
}
520516
}
521517

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,7 @@ public void testExpirationTimeDeletionPolicy() throws IOException, InterruptedEx
301301
+ (lastDeleteTime - modTime)
302302
+ " ms) but did not get deleted ",
303303
lastDeleteTime - modTime <= leeway);
304-
} catch (
305-
@SuppressWarnings("unused")
306-
IOException e) {
304+
} catch (IOException _) {
307305
// OK
308306
break;
309307
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,7 @@ public void run() {
568568
try {
569569
startingGun.await();
570570
w.addDocument(doc);
571-
} catch (
572-
@SuppressWarnings("unused")
573-
IllegalArgumentException iae) {
571+
} catch (IllegalArgumentException _) {
574572
// expected
575573
hitExc.set(true);
576574
} catch (Exception e) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ public void testCloseWhileNewWritersLocked() throws IOException, InterruptedExce
9393
latch.countDown();
9494
pool.getAndLock();
9595
fail();
96-
} catch (
97-
@SuppressWarnings("unused")
98-
AlreadyClosedException e) {
96+
} catch (AlreadyClosedException _) {
9997
// fine
10098
}
10199
});

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ public BytesRef next() throws IOException {
7575
try {
7676
// Sleep for 100ms before each .next() call.
7777
Thread.sleep(100);
78-
} catch (
79-
@SuppressWarnings("unused")
80-
InterruptedException e) {
78+
} catch (InterruptedException _) {
8179
}
8280
return in.next();
8381
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,13 @@ public void testExceptions() throws Throwable {
219219
for (int i = 0; i < 2; i++) {
220220
try {
221221
storedFields.document(i);
222-
} catch (
223-
@SuppressWarnings("unused")
224-
IOException ioe) {
222+
} catch (IOException _) {
225223
// expected
226224
exc = true;
227225
}
228226
try {
229227
storedFields.document(i);
230-
} catch (
231-
@SuppressWarnings("unused")
232-
IOException ioe) {
228+
} catch (IOException _) {
233229
// expected
234230
exc = true;
235231
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ private void implTestDeclaredMethodsOverridden(Class<?> superClass, Class<?> sub
6060
"getReturnType() difference",
6161
superClassMethod.getReturnType(),
6262
subClassMethod.getReturnType());
63-
} catch (
64-
@SuppressWarnings("unused")
65-
NoSuchMethodException e) {
63+
} catch (NoSuchMethodException _) {
6664
fail(subClass + " needs to override '" + superClassMethod + "'");
6765
}
6866
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ public void testMethodsOverridden() {
2727
if (Modifier.isFinal(m.getModifiers()) || Modifier.isPrivate(m.getModifiers())) continue;
2828
try {
2929
FilterMergePolicy.class.getDeclaredMethod(m.getName(), m.getParameterTypes());
30-
} catch (
31-
@SuppressWarnings("unused")
32-
NoSuchMethodException e) {
30+
} catch (NoSuchMethodException _) {
3331
fail("FilterMergePolicy needs to override '" + m + "'");
3432
}
3533
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ public void testTermOrd() throws Exception {
8080
assertTrue(terms.next() != null);
8181
try {
8282
assertEquals(0, terms.ord());
83-
} catch (
84-
@SuppressWarnings("unused")
85-
UnsupportedOperationException uoe) {
83+
} catch (UnsupportedOperationException _) {
8684
// ok -- codec is not required to support this op
8785
}
8886
r.close();

0 commit comments

Comments
 (0)