From 11c2268b9a1f2d8cf738ca9b132ddd5da30010cc Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Wed, 4 Mar 2020 11:08:58 +0100 Subject: [PATCH] [Minor] Changed TX to not first validate all commands executing them, but validate then do each. --- .../persistence/api/AbstractTransaction.java | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java b/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java index 7819ab151..a6427ed99 100644 --- a/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java +++ b/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java @@ -1400,7 +1400,6 @@ public abstract class AbstractTransaction implements StrolchTransaction { public void flush() { try { addModelChangeCommands(); - validateCommands(); doCommands(); writeChanges(); clearCache(); @@ -1421,13 +1420,11 @@ public abstract class AbstractTransaction implements StrolchTransaction { this.txResult.setState(TransactionState.COMMITTING); addModelChangeCommands(); - validateCommands(); doCommands(); // do it twice, since some commands might generate new model changes if (this.objectFilter != null && !this.objectFilter.isEmpty()) { addModelChangeCommands(); - validateCommands(); doCommands(); } @@ -1855,16 +1852,6 @@ public abstract class AbstractTransaction implements StrolchTransaction { return audit; } - /** - * Calls {@link Command#validate()} on all registered command. This is done before we perform any commands and thus - * no rollback needs be done due to invalid input for a command - */ - private void validateCommands() { - for (Command command : this.commands) { - command.validate(); - } - } - /** * Calls {@link Command#doCommand()} on all registered commands. This is done after the commands have been validated * so chance of a runtime exception should be small @@ -1880,6 +1867,7 @@ public abstract class AbstractTransaction implements StrolchTransaction { ListIterator iter = commands.listIterator(); while (iter.hasNext()) { Command command = iter.next(); + command.validate(); this.flushedCommands.add(command); command.doCommand(); iter.remove();