SOLR-17278: Skip broken timezones in the test
diff --git a/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java b/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java
index 11c87f5..4b102a4 100644
--- a/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java
+++ b/solr/core/src/test/org/apache/solr/util/TimeZoneUtilsTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.solr.util;
 
+import java.lang.invoke.MethodHandles;
 import java.util.HashSet;
 import java.util.Locale;
 import java.util.Random;
@@ -23,9 +24,14 @@
 import java.util.TimeZone;
 import org.apache.lucene.tests.util.TestUtil;
 import org.apache.solr.SolrTestCase;
+import org.apache.solr.common.util.SuppressForbidden;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class TimeZoneUtilsTest extends SolrTestCase {
 
+  private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
   private static void assertSameRules(
       final String label, final TimeZone expected, final TimeZone actual) {
 
@@ -39,10 +45,12 @@
     assertTrue(label + ": " + expected + " [[NOT SAME RULES]] " + actual, same);
   }
 
+  @SuppressForbidden(reason = "Using TimeZone.getDisplayName() just for warning purpose in a test")
   public void testValidIds() {
 
     final Set<String> idsTested = new HashSet<>();
 
+    int skipped = 0;
     // brain dead: anything the JVM supports, should work
     for (String validId : TimeZone.getAvailableIDs()) {
       assertTrue(
@@ -51,6 +59,20 @@
 
       final TimeZone expected = TimeZone.getTimeZone(validId);
       final TimeZone actual = TimeZoneUtils.getTimeZone(validId);
+
+      // Hack: Why do some timezones have useDaylightTime() as true, but DST as 0?
+      // It causes an exception during String.valueOf(actual/expected)
+      if (expected.useDaylightTime() && expected.getDSTSavings() == 0
+          || actual.useDaylightTime() && actual.getDSTSavings() == 0) {
+        if (log.isWarnEnabled()) {
+          log.warn(
+              "Not expecting DST to be 0 for {} " + " (actual: {})",
+              expected.getDisplayName(),
+              actual.getDisplayName());
+        }
+        skipped++;
+        continue;
+      }
       assertSameRules(validId, expected, actual);
 
       idsTested.add(validId);
@@ -58,7 +80,7 @@
 
     assertEquals(
         "TimeZone.getAvailableIDs vs TimeZoneUtils.KNOWN_TIMEZONE_IDS",
-        TimeZoneUtils.KNOWN_TIMEZONE_IDS.size(),
+        TimeZoneUtils.KNOWN_TIMEZONE_IDS.size() - skipped,
         idsTested.size());
   }