From 33efd5ed8e43732a99447404d4d481452acbc630 Mon Sep 17 00:00:00 2001 From: Ludy Date: Fri, 2 May 2025 00:20:41 +0200 Subject: [PATCH] Update DatabaseService.java --- .../security/database/DatabaseService.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) 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 b04ec37a8..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 @@ -248,22 +248,23 @@ public class DatabaseService implements DatabaseInterface { || datasource.getCustomDatabaseUrl().contains("H2"); boolean isCustomDatabase = datasource.isEnableCustomDatabase(); - if (isTypeH2 && !isDBUrlH2 && isCustomDatabase) { - 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 && isCustomDatabase) { - 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 !isCustomDatabase || isH2;