From a5b6cf1c23b872b82a09dbedade8f0ce78af5345 Mon Sep 17 00:00:00 2001 From: Bogdana Date: Thu, 22 Aug 2024 15:53:55 +0200 Subject: [PATCH] SGB-123 cover null value case for email.smtp_secure_connection.secured --- .../db/migration/version/v107/MigrateSmtpConfigurationIT.java | 3 ++- .../db/migration/version/v107/MigrateSmtpConfiguration.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v107/MigrateSmtpConfigurationIT.java b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v107/MigrateSmtpConfigurationIT.java index f40b7a22fc7..efcd150bc41 100644 --- a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v107/MigrateSmtpConfigurationIT.java +++ b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v107/MigrateSmtpConfigurationIT.java @@ -165,6 +165,7 @@ class MigrateSmtpConfigurationIT { return new Object[][]{ {"ssl", "SSLTLS"}, {"starttls", "STARTTLS"}, + {null, "NONE"}, {"", "NONE"}, {"null", "NONE"}, {"random", "NONE"} @@ -280,4 +281,4 @@ class MigrateSmtpConfigurationIT { db.executeInsert("internal_properties", "kee", key, "is_empty", false, "text_value", value, "created_at", 0); } -} \ No newline at end of file +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v107/MigrateSmtpConfiguration.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v107/MigrateSmtpConfiguration.java index 7eb56e75d9d..0ec5bbbba93 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v107/MigrateSmtpConfiguration.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v107/MigrateSmtpConfiguration.java @@ -138,7 +138,7 @@ public class MigrateSmtpConfiguration extends DataChange { } private static PropertyDb getSecureConnectionWithNewValues(PropertyDb currentProperty) { - String newValue = switch (currentProperty.value) { + String newValue = switch (currentProperty.value == null ? "" : currentProperty.value) { case "ssl" -> "SSLTLS"; case "starttls" -> "STARTTLS"; default -> "NONE"; -- 2.39.5