mirror of
https://github.com/apache/lucene.git
synced 2025-02-21 17:46:28 +00:00
SOLR-15009 Propogate IOException from DF.exists
This commit is contained in:
parent
37a61635e1
commit
cb5ba42bd7
@ -205,6 +205,8 @@ Bug Fixes
|
||||
|
||||
* SOLR-14851: Http2SolrClient doesn't handle keystore type correctly (Andras Salamon via janhoy)
|
||||
|
||||
* SOLR-15009: Correctly propogate exceptions from DirectoryFactory.exists (Mike Drob)
|
||||
|
||||
Other Changes
|
||||
---------------------
|
||||
|
||||
|
@ -16,9 +16,11 @@
|
||||
*/
|
||||
package org.apache.solr.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -323,9 +325,14 @@ public abstract class CachingDirectoryFactory extends DirectoryFactory {
|
||||
|
||||
@Override
|
||||
public boolean exists(String path) throws IOException {
|
||||
// back compat behavior
|
||||
File dirFile = new File(path);
|
||||
return dirFile.canRead() && dirFile.list().length > 0;
|
||||
// we go by the persistent storage ...
|
||||
Path dirPath = Path.of(path);
|
||||
if (Files.isReadable(dirPath)) {
|
||||
try (DirectoryStream<Path> directory = Files.newDirectoryStream(dirPath)) {
|
||||
return directory.iterator().hasNext();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -84,24 +84,11 @@ public class StandardDirectoryFactory extends CachingDirectoryFactory {
|
||||
|
||||
return super.normalize(cpath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(String path) throws IOException {
|
||||
// we go by the persistent storage ...
|
||||
File dirFile = new File(path);
|
||||
return dirFile.canRead() && dirFile.list().length > 0;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPersistent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbsolute(String path) {
|
||||
// back compat
|
||||
return new File(path).isAbsolute();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeDirectory(CacheValue cacheValue) throws IOException {
|
||||
File dirFile = new File(cacheValue.path);
|
||||
|
Loading…
x
Reference in New Issue
Block a user