Skip to content

Commit

Permalink
Add assertions
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <[email protected]>
  • Loading branch information
Sachin Kale committed Oct 29, 2023
1 parent 62e396a commit c8720eb
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.apache.lucene.store.IndexOutput;
import org.opensearch.index.store.RemoteBufferedOutputDirectory;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.NoSuchFileException;
import java.util.Collection;
Expand Down Expand Up @@ -78,6 +79,10 @@ public String fetchLock(String filenamePrefix, String acquirerId) throws IOExcep
.filter(lockFile -> acquirerId.equals(FileLockInfo.LockFileUtils.getAcquirerIdFromLock(lockFile)))
.map(FileLockInfo.LockFileUtils::getFileToLockNameFromLock)
.collect(Collectors.toList());
if (lockFilesForAcquirer.size() == 0) {
throw new FileNotFoundException("No lock file found for prefix: " + filenamePrefix + " and acquirerId: " + acquirerId);
}
assert lockFilesForAcquirer.size() == 1;
return lockFilesForAcquirer.get(0);
}

Expand Down

0 comments on commit c8720eb

Please sign in to comment.