From: jsimomaa Date: Mon, 25 Nov 2019 07:14:04 +0000 (+0200) Subject: SCLFunctions.syncWrite does not check if graph is WriteGraph X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F13%2F3613%2F1;p=simantics%2Fplatform.git SCLFunctions.syncWrite does not check if graph is WriteGraph gitlab #425 Change-Id: Icb771e425c170e00385b943a6a6dde2cf62e2d9b --- diff --git a/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java b/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java index 09022d543..9f242b28c 100644 --- a/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java +++ b/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java @@ -254,9 +254,14 @@ public class SCLFunctions { public static 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() { @Override