Skip to content

Commit

Permalink
#29240 include in 23.10.24 LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Jul 19, 2024
1 parent 8caa088 commit 1ac7e02
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
3 changes: 2 additions & 1 deletion dotCMS/hotfix_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ This maintenance release includes the following code fixes:
118. https://github.com/dotCMS/core/issues/26421 : Block Editor: Add align-justify option to menu #26421
119. https://github.com/dotCMS/core/issues/27537 : Download database not working in latest version #27537
120. https://github.com/dotCMS/core/issues/27871 : refactor pg_dump inclusion in our docker image #27871
121. SI-72
121. SI-72
122. https://github.com/dotCMS/core/issues/29240 : UT keep running even though one failed #29240
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dotmarketing.startup;

import com.dotmarketing.exception.DotHibernateException;
import com.google.common.annotations.VisibleForTesting;
import java.sql.Connection;
import java.util.Date;
Expand Down Expand Up @@ -199,12 +200,7 @@ public void executeStartUpTasks() throws DotDataException {
}
Logger.info(this, "Finishing startup tasks.");
} catch (Throwable e) {
HibernateUtil.rollbackTransaction();
Logger.error(this, "FATAL: Unable to execute the upgrade task : " + name, e);
if(Config.getBooleanProperty("SYSTEM_EXIT_ON_STARTUP_FAILURE", true)){
e.printStackTrace();
System.exit(1);
}
taskFailure(e);
} finally {
// This will commit the changes and close the connection
HibernateUtil.closeAndCommitTransaction();
Expand Down Expand Up @@ -270,11 +266,7 @@ public void executeSchemaUpgrades() throws DotDataException {
Config.DB_VERSION = taskId;
}
} catch (Exception e) {
HibernateUtil.rollbackTransaction();
if (Config.getBooleanProperty("SYSTEM_EXIT_ON_STARTUP_FAILURE", true)) {
Logger.error(this, "FATAL: " +e.getMessage(),e);
System.exit(1);
}
taskFailure(e);
} finally {
HibernateUtil.closeAndCommitTransaction();
}
Expand Down Expand Up @@ -338,11 +330,7 @@ public void executeDataUpgrades() throws DotDataException {
Config.DATA_VERSION = taskId;
}
} catch (Exception e) {
HibernateUtil.rollbackTransaction();
if (Config.getBooleanProperty("SYSTEM_EXIT_ON_STARTUP_FAILURE", true)) {
Logger.error(this, "FATAL: " + e.getMessage(), e);
System.exit(1);
}
taskFailure(e);
} finally {
HibernateUtil.closeAndCommitTransaction();
}
Expand Down Expand Up @@ -386,12 +374,7 @@ public void executeBackportedTasks() throws DotDataException {
}
Logger.info(this, "Finishing Backported tasks.");
} catch (Throwable e) {
HibernateUtil.rollbackTransaction();
Logger.error(this, "FATAL: Unable to execute the upgrade task : " + name, e);
if(Config.getBooleanProperty("SYSTEM_EXIT_ON_STARTUP_FAILURE", true)){
e.printStackTrace();
System.exit(1);
}
taskFailure(e);
} finally {
// This will commit the changes and close the connection
HibernateUtil.closeAndCommitTransaction();
Expand All @@ -400,6 +383,25 @@ public void executeBackportedTasks() throws DotDataException {

}

private void taskFailure(Throwable e) throws DotHibernateException {
HibernateUtil.rollbackTransaction();
for(int i = 0; i < 3; i++){
System.err.println("FATAL ERROR RUNNING TASK: " + e.getMessage());
Logger.error(this, "FATAL ERROR RUNNING TASK: " + e.getMessage(), e);
}

e.printStackTrace();

if (Config.getBooleanProperty("SYSTEM_EXIT_ON_STARTUP_FAILURE", true)) {
try {
Thread.sleep(10000);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
Logger.debug(this,"Thread was interrupted", ex);
}
System.exit(1);
}
}


}
2 changes: 1 addition & 1 deletion dotCMS/src/main/resources/dotmarketing-config.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SYSTEM_EXIT_ON_STARTUP_FAILURE=false
SYSTEM_EXIT_ON_STARTUP_FAILURE=true
CONTENT_PALETTE_HIDDEN_CONTENT_TYPES=Host,Vanityurl,Languagevariable,persona,forms

EMAIL_SYSTEM_ADDRESS = [email protected]
Expand Down

0 comments on commit 1ac7e02

Please sign in to comment.