Skip to content

Commit

Permalink
Fix Java 8 _ variable warning
Browse files Browse the repository at this point in the history
The _ variable causes a warning when compiling with Java 8, noting that it might be removed in a future version
  • Loading branch information
kimchy committed Mar 6, 2015
1 parent c5a6767 commit 0a3175a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/elasticsearch/common/lucene/Lucene.java
Expand Up @@ -177,7 +177,7 @@ public static SegmentInfos pruneUnreferencedFiles(String segmentsFileName, Direc
}
}
final CommitPoint cp = new CommitPoint(si, directory);
try (IndexWriter _ = new IndexWriter(directory, new IndexWriterConfig(Lucene.STANDARD_ANALYZER)
try (IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(Lucene.STANDARD_ANALYZER)
.setIndexCommit(cp)
.setCommitOnClose(false)
.setMergePolicy(NoMergePolicy.INSTANCE)
Expand All @@ -203,7 +203,7 @@ public static void cleanLuceneIndex(Directory directory) throws IOException {
}
}
}
try (IndexWriter _ = new IndexWriter(directory, new IndexWriterConfig(Lucene.STANDARD_ANALYZER)
try (IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(Lucene.STANDARD_ANALYZER)
.setMergePolicy(NoMergePolicy.INSTANCE) // no merges
.setCommitOnClose(false) // no commits
.setOpenMode(IndexWriterConfig.OpenMode.CREATE))) // force creation - don't append...
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/org/elasticsearch/index/engine/InternalEngine.java
Expand Up @@ -203,7 +203,7 @@ private void updateIndexWriterSettings() {

@Override
public GetResult get(Get get) throws EngineException {
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
if (get.realtime()) {
VersionValue versionValue = versionMap.getUnderLock(get.uid().bytes());
Expand Down Expand Up @@ -232,7 +232,7 @@ public GetResult get(Get get) throws EngineException {

@Override
public void create(Create create) throws EngineException {
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
if (create.origin() == Operation.Origin.RECOVERY) {
// Don't throttle recovery operations
Expand Down Expand Up @@ -338,7 +338,7 @@ private void innerCreateNoLock(Create create, long currentVersion, VersionValue

@Override
public void index(Index index) throws EngineException {
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
if (index.origin() == Operation.Origin.RECOVERY) {
// Don't throttle recovery operations
Expand Down Expand Up @@ -438,7 +438,7 @@ private void innerIndex(Index index) throws IOException {

@Override
public void delete(Delete delete) throws EngineException {
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
// NOTE: we don't throttle this when merges fall behind because delete-by-id does not create new segments:
innerDelete(delete);
Expand Down Expand Up @@ -506,7 +506,7 @@ private void innerDelete(Delete delete) throws IOException {

@Override
public void delete(DeleteByQuery delete) throws EngineException {
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
if (delete.origin() == Operation.Origin.RECOVERY) {
// Don't throttle recovery operations
Expand Down Expand Up @@ -549,7 +549,7 @@ private void innerDelete(DeleteByQuery delete) throws EngineException {
public void refresh(String source) throws EngineException {
// we obtain a read lock here, since we don't want a flush to happen while we are refreshing
// since it flushes the index as well (though, in terms of concurrency, we are allowed to do it)
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
updateIndexWriterSettings();
searcherManager.maybeRefreshBlocking();
Expand Down Expand Up @@ -594,7 +594,7 @@ private void flush(boolean commitTranslog, boolean force, boolean waitIfOngoing)
* Thread 1: flushes via API and gets the flush lock but blocks on the readlock since Thread 2 has the writeLock
* Thread 2: flushes at the end of the recovery holding the writeLock and blocks on the flushLock owned by Thread 1
*/
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
updateIndexWriterSettings();
if (flushLock.tryLock() == false) {
Expand Down Expand Up @@ -731,7 +731,7 @@ private void waitForMerges(boolean flushAfter, boolean upgrade) {
@Override
public void forceMerge(final boolean flush, int maxNumSegments, boolean onlyExpungeDeletes, final boolean upgrade) throws EngineException {
if (optimizeMutex.compareAndSet(false, true)) {
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
/*
* The way we implement upgrades is a bit hackish in the sense that we set an instance
Expand Down Expand Up @@ -770,7 +770,7 @@ public SnapshotIndexCommit snapshotIndex() throws EngineException {
// we have to flush outside of the readlock otherwise we might have a problem upgrading
// the to a write lock when we fail the engine in this operation
flush(false, false, true);
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
return deletionPolicy.snapshot();
} catch (IOException e) {
Expand All @@ -782,7 +782,7 @@ public SnapshotIndexCommit snapshotIndex() throws EngineException {
public void recover(RecoveryHandler recoveryHandler) throws EngineException {
// take a write lock here so it won't happen while a flush is in progress
// this means that next commits will not be allowed once the lock is released
try (ReleasableLock _ = writeLock.acquire()) {
try (ReleasableLock lock = writeLock.acquire()) {
ensureOpen();
onGoingRecoveries.startRecovery();
}
Expand Down Expand Up @@ -871,7 +871,7 @@ protected final void writerSegmentStats(SegmentsStats stats) {

@Override
public List<Segment> segments(boolean verbose) {
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
Segment[] segmentsArr = getSegmentInfo(lastCommittedSegmentInfos, verbose);

// fill in the merges flag
Expand Down
Expand Up @@ -130,7 +130,7 @@ public void flush(boolean force, boolean waitIfOngoing) throws EngineException {
* we can't use it.
*/
store.incRef();
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
// reread the last committed segment infos
lastCommittedSegmentInfos = store.readLastCommittedSegmentsInfo();
} catch (Throwable e) {
Expand Down Expand Up @@ -159,7 +159,7 @@ public GetResult get(Get get) throws EngineException {

@Override
public List<Segment> segments(boolean verbose) {
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
Segment[] segmentsArr = getSegmentInfo(lastCommittedSegmentInfos, verbose);
for (int i = 0; i < segmentsArr.length; i++) {
// hard code all segments as committed, because they are in
Expand All @@ -174,7 +174,7 @@ public List<Segment> segments(boolean verbose) {
public void refresh(String source) throws EngineException {
// we obtain a read lock here, since we don't want a flush to happen while we are refreshing
// since it flushes the index as well (though, in terms of concurrency, we are allowed to do it)
try (ReleasableLock _ = readLock.acquire()) {
try (ReleasableLock lock = readLock.acquire()) {
ensureOpen();
searcherManager.maybeRefreshBlocking();
} catch (AlreadyClosedException e) {
Expand Down

0 comments on commit 0a3175a

Please sign in to comment.