diff --git a/src/main/java/stirling/software/SPDF/config/security/database/DatabaseService.java b/src/main/java/stirling/software/SPDF/config/security/database/DatabaseService.java index 04b470f92..27e9ae7b1 100644 --- a/src/main/java/stirling/software/SPDF/config/security/database/DatabaseService.java +++ b/src/main/java/stirling/software/SPDF/config/security/database/DatabaseService.java @@ -246,26 +246,28 @@ public class DatabaseService implements DatabaseInterface { boolean isDBUrlH2 = datasource.getCustomDatabaseUrl().contains("h2") || datasource.getCustomDatabaseUrl().contains("H2"); + boolean isCustomDatabase = datasource.isEnableCustomDatabase(); - if (isTypeH2 && !isDBUrlH2) { - log.warn( - "Datasource type is H2, but the URL does not contain 'h2'. " - + "Please check your configuration."); - throw new IllegalStateException( - "Datasource type is H2, but the URL does not contain 'h2'. Please check your" - + " configuration."); - } else if (!isTypeH2 && isDBUrlH2) { - log.warn( - "Datasource URL contains 'h2', but the type is not H2. " - + "Please check your configuration."); - throw new IllegalStateException( - "Datasource URL contains 'h2', but the type is not H2. Please check your" - + " configuration."); + if (isCustomDatabase) { + if (isTypeH2 && !isDBUrlH2) { + log.warn( + "Datasource type is H2, but the URL does not contain 'h2'. " + + "Please check your configuration."); + throw new IllegalStateException( + "Datasource type is H2, but the URL does not contain 'h2'. Please check" + + " your configuration."); + } else if (!isTypeH2 && isDBUrlH2) { + log.warn( + "Datasource URL contains 'h2', but the type is not H2. " + + "Please check your configuration."); + throw new IllegalStateException( + "Datasource URL contains 'h2', but the type is not H2. Please check your" + + " configuration."); + } } - boolean isH2 = isTypeH2 && isDBUrlH2; - return !datasource.isEnableCustomDatabase() || isH2; + return !isCustomDatabase || isH2; } /**