suneet-s commented on a change in pull request #11423:
URL: https://github.com/apache/druid/pull/11423#discussion_r666693115



##########
File path: core/src/main/java/org/apache/druid/java/util/common/DateTimes.java
##########
@@ -53,14 +57,28 @@
       
"[0-9]{4}-[01][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-5][0-9]\\.[0-9]{3}(Z|[+\\-][0-9]{2}(:[0-9]{2}))"
   );
 
-  @SuppressForbidden(reason = "DateTimeZone#forID")
   public static DateTimeZone inferTzFromString(String tzId)
+  {
+    return inferTzFromString(tzId, true);
+  }
+
+  /**
+   * @return The dateTimezone for the provided {@param tzId}. If {@param 
fallback} is true, the default timezone
+   * will be returned if the tzId does not match a supported timezone.
+   * @throws IllegalArgumentException if {@param fallback} is false and the 
provided tzId doesn't match a supported
+   * timezone.
+   */
+  @SuppressForbidden(reason = "DateTimeZone#forID")
+  public static DateTimeZone inferTzFromString(String tzId, boolean fallback) 
throws IllegalArgumentException
   {
     try {
       return DateTimeZone.forID(tzId);
     }
     catch (IllegalArgumentException e) {
       // also support Java timezone strings
+      if (!fallback && !AVAILABLE_TIMEZONE_IDS.contains(tzId)) {
+        throw e;

Review comment:
       `The datetime zone id 'America/Unknown' is not recognised` is the error 
message in the tests. I'm not sure if it's better form to standardize the error 
message or not, but I didn't feel like logging the error message and throwing a 
sanitized error message instead. Let me know if you think another error message 
will be better.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to