From 0523cedb6788769905ae3599829ed77b58756456 Mon Sep 17 00:00:00 2001 From: Jym Dyer Date: Wed, 8 Nov 2023 17:09:58 -0800 Subject: [PATCH] The #getTwilioLocale() switch can't be null (until JDK 21) so add a check. --- .../opentripplanner/middleware/utils/NotificationUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/opentripplanner/middleware/utils/NotificationUtils.java b/src/main/java/org/opentripplanner/middleware/utils/NotificationUtils.java index 115e9e6c2..a9df3d3e7 100644 --- a/src/main/java/org/opentripplanner/middleware/utils/NotificationUtils.java +++ b/src/main/java/org/opentripplanner/middleware/utils/NotificationUtils.java @@ -148,6 +148,9 @@ public static String sendSMS(String toPhone, String body) { * See https://www.twilio.com/docs/verify/supported-languages#verify-default-template */ public static String getTwilioLocale(String locale) { + if (locale == null) { + return "en"; + } // The Twilio's supported locales are just the first two letters of the user's locale, // unless it is zh-HK, pt-BR, or en-GB. switch (locale) { @@ -156,7 +159,7 @@ public static String getTwilioLocale(String locale) { case "zh-HK": return locale; default: - return locale == null || locale.length() < 2 ? "en" : locale.substring(0, 2); + return locale.length() < 2 ? "en" : locale.substring(0, 2); } }