Runnable: replace anonymous class with lambda

In Java 8 Runnable is functional interface and can be replaced with
lambda expressions or method references.

Change-Id: I2896b39c27b2e5a91a60149155a8c00a8eb48e39
This commit is contained in:
David Ostrovsky
2017-03-26 13:03:21 +02:00
committed by Shawn Pearce
parent 8f0528f3b5
commit 8785d73fa5
30 changed files with 493 additions and 799 deletions

View File

@@ -121,28 +121,25 @@ public abstract class AbstractLuceneIndex<K, V> implements Index<K, V> {
@SuppressWarnings("unused") // Error handling within Runnable.
Future<?> possiblyIgnoredError =
autoCommitExecutor.scheduleAtFixedRate(
new Runnable() {
@Override
public void run() {
() -> {
try {
if (autoCommitWriter.hasUncommittedChanges()) {
autoCommitWriter.manualFlush();
autoCommitWriter.commit();
}
} catch (IOException e) {
log.error("Error committing " + index + " Lucene index", e);
} catch (OutOfMemoryError e) {
log.error("Error committing " + index + " Lucene index", e);
try {
if (autoCommitWriter.hasUncommittedChanges()) {
autoCommitWriter.manualFlush();
autoCommitWriter.commit();
}
} catch (IOException e) {
log.error("Error committing " + index + " Lucene index", e);
} catch (OutOfMemoryError e) {
log.error("Error committing " + index + " Lucene index", e);
try {
autoCommitWriter.close();
} catch (IOException e2) {
log.error(
"SEVERE: Error closing "
+ index
+ " Lucene index after OOM;"
+ " index may be corrupted.",
e);
}
autoCommitWriter.close();
} catch (IOException e2) {
log.error(
"SEVERE: Error closing "
+ index
+ " Lucene index after OOM;"
+ " index may be corrupted.",
e);
}
}
},