Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8239836

ZoneRules.of() doesn't check transitionList/standardOffsetTL arguments validity

    XMLWordPrintable

Details

    • b14
    • Not verified

    Description

      A DESCRIPTION OF THE PROBLEM :
      ZoneRules.of() implies that transitionList is a superset of standardOffsetTransitionList but doesn't check that. Then it's possible to construct ZoneRules instances that don't work correctly.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      IllegalArgumentException from ZoneRules.of()
      ACTUAL -
      AssertionError

      ---------- BEGIN SOURCE ----------
          @Test
          public void zoneRulesTest() {
              LocalDateTime transitionDay = LocalDateTime.of(2020, 1, 1, 2, 0);
              ZoneOffsetTransition trans = ZoneOffsetTransition.of(
                      transitionDay,
                      ZoneOffset.ofHours(1),
                      ZoneOffset.ofHours(2)
              );
              ZoneRules rules = ZoneRules.of(ZoneOffset.ofHours(1), ZoneOffset.ofHours(1),
                      Arrays.asList(trans),
                      Collections.emptyList(), Collections.emptyList());

              Assert.assertEquals(ZoneOffset.ofHours(2), rules.getOffset(
                      transitionDay.plusDays(7).toInstant(ZoneOffset.UTC)));
          }
      ---------- END SOURCE ----------

      Attachments

        Activity

          People

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: