You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2018/01/29 23:16:34 UTC

[isis] 01/04: ISIS-1569: fixes issue to fail-fast.

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-1569-replay-commands
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 19dfb5324cf32c9fd1015ab01308439fe313d76b
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Jan 29 14:23:43 2018 +0000

    ISIS-1569: fixes issue to fail-fast.
---
 .../background/BackgroundCommandExecution.java     | 23 +++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
index ec2ee0e..b408af3 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/background/BackgroundCommandExecution.java
@@ -50,6 +50,7 @@ import org.apache.isis.core.runtime.sessiontemplate.AbstractIsisSessionTemplate;
 import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
 import org.apache.isis.core.runtime.system.transaction.TransactionalClosure;
+import org.apache.isis.core.runtime.system.transaction.TransactionalClosureWithReturn;
 import org.apache.isis.schema.cmd.v1.ActionDto;
 import org.apache.isis.schema.cmd.v1.CommandDto;
 import org.apache.isis.schema.cmd.v1.MemberDto;
@@ -116,7 +117,12 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
         LOG.info("Found {} to execute", backgroundCommands.size());
 
         for (final Command backgroundCommand : backgroundCommands) {
-            execute(transactionManager, backgroundCommand);
+            final boolean shouldContinue = execute(transactionManager, backgroundCommand);
+            if(!shouldContinue) {
+                LOG.info("OnExceptionPolicy is to QUIT, so skipping further processing",
+                        backgroundCommand.getMemberIdentifier());
+                return;
+            }
         }
     }
 
@@ -128,15 +134,15 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
     // //////////////////////////////////////
 
     
-    private void execute(
+    private boolean execute(
             final IsisTransactionManager transactionManager,
             final Command backgroundCommand) {
 
-        transactionManager.executeWithinTransaction(
+        return transactionManager.executeWithinTransaction(
                 backgroundCommand,
-                new TransactionalClosure() {
+                new TransactionalClosureWithReturn<Boolean>() {
             @Override
-            public void execute() {
+            public Boolean execute() {
 
                 // setup for us by IsisTransactionManager; will have the transactionId of the backgroundCommand
                 final Interaction backgroundInteraction = interactionContext.getInteraction();
@@ -291,10 +297,9 @@ public abstract class BackgroundCommandExecution extends AbstractIsisSessionTemp
                 backgroundCommand.setCompletedAt(completedAt);
 
                 // if we hit an exception processing this command, then quit if instructed
-                if(exceptionIfAny != null && onExceptionPolicy == OnExceptionPolicy.QUIT) {
-                    LOG.info("OnExceptionPolicy is to QUIT, so skipping further processing", backgroundCommand.getMemberIdentifier());
-                    return;
-                }
+                final boolean shouldQuit = exceptionIfAny != null && onExceptionPolicy == OnExceptionPolicy.QUIT;
+                final boolean shouldContinue = !shouldQuit;
+                return shouldContinue;
 
             }
 

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.