delete() calls close()
@@ -18,6 +18,7 @@ import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -105,18 +106,15 @@ public class DocumentStore {
eventBus.post(new DatabaseClosed(databaseName));
}
- @SuppressWarnings("unchecked")
public void delete() throws IOException {
- synchronized (documentStores) {
- DocumentStore ds = documentStores.remove(location);
- if (ds != null) {
- ((DatabaseImpl)database).close();
- ((IndexManagerImpl)query).close();
+ try {
+ this.close();
+ } catch (Exception e) {
+ // caught exception could be something benign like datastore already closed, so just log
+ logger.log(Level.WARNING, "Caught exception whilst closing DocumentStore in delete()", e);
}
if (!location.exists()) {
- String msg = String.format(
- "Datastore %s doesn't exist on disk", location
- );
+ String msg = String.format("Datastore %s doesn't exist on disk", location);
logger.warning(msg);
throw new IOException(msg);
} else {
@@ -124,7 +122,6 @@ public class DocumentStore {
eventBus.post(new DatabaseDeleted(databaseName));
}
}
- }
public static EventBus getEventBus() {
return eventBus;
