X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.indexing%2Fsrc%2Forg%2Fsimantics%2Fdb%2Findexing%2FIndexedRelationsSearcherBase.java;h=b303dfc4c4b1fc73f2b10eba9363cab20ddabfb0;hp=92cbe56d12bacfa76d30696811d90a01cfe4f00f;hb=bdbcaeeef059e97bcaba696f129deb1d5c16c0bf;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07 diff --git a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java index 92cbe56d1..b303dfc4c 100644 --- a/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java +++ b/bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java @@ -14,6 +14,8 @@ package org.simantics.db.indexing; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -577,7 +579,7 @@ abstract public class IndexedRelationsSearcherBase { @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, "Lucene Index Creator"); - if (t.isDaemon()) + if (!t.isDaemon()) t.setDaemon(true); if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY); @@ -708,7 +710,7 @@ abstract public class IndexedRelationsSearcherBase { try { closeWriter(writer.getAndSet(null)); } finally { - directory.getAndSet(null).close(); + FileUtils.uncheckedClose(directory.getAndSet(null)); } } } @@ -981,13 +983,10 @@ abstract public class IndexedRelationsSearcherBase { } private static void createDirectory(File path) throws IOException { - if (path.exists() && !path.isDirectory()) - throw new IOException("Could not create index directory " + path + ", a file by that name already exists"); - path.mkdirs(); - if (!path.exists()) - throw new IOException("Could not create index directory " + path + " for an unknown reason"); - if (!path.isDirectory()) + Path p = path.toPath(); + if (Files.exists(p) && !Files.isDirectory(p)) throw new IOException("Could not create index directory " + path + ", a file by that name already exists"); + Files.createDirectories(p); } File getIndexPath() {