]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.common/src/org/simantics/db/common/utils/RequestUtil.java
Use listener as listener in TimeoutingRequest
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / utils / RequestUtil.java
index 3ab4d2644f567ae5e054c7fa02d600e821398706..d1256444ba7f2ce52c51680320b556bb27bb94b3 100644 (file)
@@ -8,6 +8,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Session;
 
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.procedure.Listener;
 import org.simantics.db.procedure.Procedure;
 import org.simantics.db.request.Read;
 
@@ -95,9 +96,15 @@ public final class RequestUtil {
                public R perform(ReadGraph graph) throws DatabaseException {
                        if (state.compareAndSet(0, 1)) {
                                release();
-                               return wrappedProcedure != null
-                                               ? graph.syncRequest(wrappedRequest, wrappedProcedure)
-                                               : graph.syncRequest(wrappedRequest);
+                               if(wrappedProcedure != null) {
+                                       if(wrappedProcedure instanceof Listener<?>) {
+                                               return graph.syncRequest(wrappedRequest, (Listener<R>)wrappedProcedure);
+                                       } else {
+                                               return graph.syncRequest(wrappedRequest, wrappedProcedure);
+                                       }
+                               } else {
+                                       return graph.syncRequest(wrappedRequest);
+                               }
                        } else {
                                if (TRACE_TIMEOUT)
                                        System.out.println("[" + System.currentTimeMillis() + "] canceling execution of request " + wrappedRequest + ", startup timed out");