fix: make sure to stop scheduling of view refresh before closing the OrientDB instance
@@ -989,6 +989,7 @@ public class OrientDBEmbedded implements OrientDBInternal {
timer.cancel();
securitySystem.shutdown();
executor.shutdown();
+ preClose();
try {
while (!executor.awaitTermination(1, TimeUnit.MINUTES)) {
OLogManager.instance().warn(this, "Failed waiting background operations termination");
@@ -1005,6 +1006,11 @@ public class OrientDBEmbedded implements OrientDBInternal {
removeShutdownHook();
}
+ public synchronized void preClose() {
+ if (!open) return;
+ this.sharedContexts.values().forEach(x -> x.getViewManager().close());
+ }
+
public synchronized void internalClose() {
if (!open) return;
open = false;
@@ -1172,9 +1178,15 @@ public class OrientDBEmbedded implements OrientDBInternal {
public <X> Future<X> executeNoAuthorization(String database, ODatabaseTask<X> task) {
return executor.submit(
() -> {
+ if (isOpen()) {
try (ODatabaseSession session = openNoAuthorization(database)) {
return task.call(session);
}
+ } else {
+ OLogManager.instance()
+ .warn(this, " Cancelled execution of task, OrientDB instance is closed");
+ return null;
+ }
});
}
