]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
SCLFunctions.syncWrite does not check if graph is WriteGraph 13/3613/1
authorjsimomaa <jani.simomaa@gmail.com>
Mon, 25 Nov 2019 07:14:04 +0000 (09:14 +0200)
committerjsimomaa <jani.simomaa@gmail.com>
Mon, 25 Nov 2019 07:14:04 +0000 (09:14 +0200)
gitlab #425

Change-Id: Icb771e425c170e00385b943a6a6dde2cf62e2d9b

bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java

index 09022d543c1aba3e9101028c88ed939b72759963..9f242b28c8efade8dc8d606d4c6409bd94b86a69 100644 (file)
@@ -254,9 +254,14 @@ public class SCLFunctions {
     public static <T> T syncWrite(final Function f, final Object ... args) throws DatabaseException {
         final SCLContext context = SCLContext.getCurrent();
         Object graph = context.get(GRAPH);
-        if (graph != null) {
+        if (graph != null && graph instanceof WriteGraph) {
             return (T)f.apply(Tuple0.INSTANCE);
         } else {
+            if (graph != null) {
+                LOGGER.error(
+                        "SCLContext {} for current thread {} contains an existing graph object but it is not WriteGraph - Somewhere is a function that forgets to remove the graph from the context!!",
+                        context, Thread.currentThread());
+            }
             final SCLReportingHandler printer = (SCLReportingHandler)SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER);
             return Simantics.getSession().syncRequest(new WriteResultRequest<T>() {
                 @Override