Skip to content

Commit

Permalink
fix breaking changes introduced in #6565 (#6571)
Browse files Browse the repository at this point in the history
PR #6565 introduced a few breaking changes to the pro builds, and a change that was not related to the intention of the original PR. This PR fixes those breaking changes and reintroduces the removal of code that was unrelated to the original PR.
  • Loading branch information
StevenMassaro authored Dec 9, 2024
1 parent 32de1cf commit ff2b0c9
Showing 1 changed file with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import liquibase.change.core.SQLFileChange;
import liquibase.change.visitor.ChangeVisitor;
import liquibase.changelog.visitor.ChangeExecListener;
import liquibase.command.CommandScope;
import liquibase.configuration.LiquibaseConfiguration;
import liquibase.database.Database;
import liquibase.database.DatabaseList;
Expand Down Expand Up @@ -668,7 +669,7 @@ public ExecType execute(DatabaseChangeLog databaseChangeLog, ChangeExecListener
return ExecType.MARK_RAN;
}

startInstant = Instant.now();
setStartTime();
getCurrentScope().addMdcValue(MdcKey.CHANGESET_OPERATION_START_TIME, startInstant.toString());

boolean skipChange = false;
Expand Down Expand Up @@ -802,7 +803,7 @@ public ExecType execute(DatabaseChangeLog databaseChangeLog, ChangeExecListener
execType = ExecType.EXECUTED;
}

stopInstant = Instant.now();
setStopTime();
getCurrentScope().addMdcValue(MdcKey.CHANGESET_OPERATION_STOP_TIME, stopInstant.toString());
getCurrentScope().addMdcValue(MdcKey.CHANGESET_OUTCOME, execType.value.toLowerCase());
log.info("ChangeSet " + toString(false) + " ran successfully in " + getExecutionMilliseconds() + "ms");
Expand All @@ -811,11 +812,17 @@ public ExecType execute(DatabaseChangeLog databaseChangeLog, ChangeExecListener
}

} catch (Exception e) {
stopInstant = Instant.now();
setStopTime();
getCurrentScope().addMdcValue(MdcKey.CHANGESET_OPERATION_STOP_TIME, stopInstant.toString());
getCurrentScope().addMdcValue(MdcKey.CHANGESET_OUTCOME, ExecType.FAILED.value.toLowerCase());
log.severe(String.format("ChangeSet %s encountered an exception.", toString(false)), e);
setErrorMsg(e.getMessage());

//
// Set the suppression flag so that additional logging of the exception won't happen
//
CommandScope.suppressExceptionLogging(true);

try {
database.rollback();
} catch (Exception e1) {
Expand Down Expand Up @@ -847,6 +854,16 @@ public ExecType execute(DatabaseChangeLog databaseChangeLog, ChangeExecListener
return execType;
}

private void setStopTime() {
stopInstant = Instant.now();
operationStopTime = Date.from(stopInstant);
}

private void setStartTime() {
startInstant = Instant.now();
operationStartTime = Date.from(startInstant);
}

//
// Get the custom Executor ready if necessary
// We do not do anything if we have a LoggingExecutor.
Expand Down Expand Up @@ -908,7 +925,7 @@ public void rollback(Database database) throws RollbackFailedException {
}

public void rollback(Database database, ChangeExecListener listener) throws RollbackFailedException {
startInstant = Instant.now();
setStartTime();
getCurrentScope().addMdcValue(MdcKey.CHANGESET_OPERATION_START_TIME, startInstant.toString());
addChangeSetMdcProperties();
getCurrentScope().addMdcValue(MdcKey.DEPLOYMENT_ID, getDeploymentId());
Expand Down Expand Up @@ -974,7 +991,7 @@ public void rollback(Database database, ChangeExecListener listener) throws Roll
if (runInTransaction) {
database.commit();
}
stopInstant = Instant.now();
setStopTime();
rollbackExecType = ExecType.EXECUTED;
getCurrentScope().addMdcValue(MdcKey.CHANGESET_OUTCOME, ExecType.EXECUTED.value.toLowerCase());
getCurrentScope().addMdcValue(MdcKey.CHANGESET_OPERATION_STOP_TIME, stopInstant.toString());
Expand Down

0 comments on commit ff2b0c9

Please sign in to comment.