mirror of https://github.com/apache/lucene.git
SOLR-7168: Test failure :Could not remove the files in windows
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1662677 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
60d117b7cb
commit
0a169719c7
|
@ -797,7 +797,6 @@ public class SolrResourceLoader implements ResourceLoader,Closeable
|
||||||
public static void persistConfLocally(SolrResourceLoader loader, String resourceName, byte[] content) {
|
public static void persistConfLocally(SolrResourceLoader loader, String resourceName, byte[] content) {
|
||||||
// Persist locally
|
// Persist locally
|
||||||
File confFile = new File(loader.getConfigDir(), resourceName);
|
File confFile = new File(loader.getConfigDir(), resourceName);
|
||||||
OutputStream out = null;
|
|
||||||
try {
|
try {
|
||||||
File parentDir = confFile.getParentFile();
|
File parentDir = confFile.getParentFile();
|
||||||
if ( ! parentDir.isDirectory()) {
|
if ( ! parentDir.isDirectory()) {
|
||||||
|
@ -807,17 +806,17 @@ public class SolrResourceLoader implements ResourceLoader,Closeable
|
||||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg);
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out = new FileOutputStream(confFile);
|
try (OutputStream out = new FileOutputStream(confFile);) {
|
||||||
out.write(content);
|
out.write(content);
|
||||||
|
}
|
||||||
log.info("Written confile " + resourceName);
|
log.info("Written confile " + resourceName);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
final String msg = "Error persisting conf file " + resourceName;
|
final String msg = "Error persisting conf file " + resourceName;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg, e);
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
org.apache.commons.io.IOUtils.closeQuietly(out);
|
|
||||||
try {
|
try {
|
||||||
FileUtils.sync(confFile);
|
IOUtils.fsync(confFile.toPath(), false);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
final String msg = "Error syncing conf file " + resourceName;
|
final String msg = "Error syncing conf file " + resourceName;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
|
Loading…
Reference in New Issue