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

api/java_time/tck/java/time/format/index.html#TCKDateTimeFormatter has testcase that fails sometimes

    Details

    • Subcomponent:
    • Resolved In Build:
      b91
    • Verification:
      Verified

      Description

      The testcase

      api/java_time/tck/java/time/format/index.html#TCKDateTimeFormatter[test_resolverFields_selectOneDateResolveYD]

      might fail in some modes - the failure could be seen for example in SingleJVM and MultiJVM but might not be reproducible with GroupJVM mode

      However it is reproducible as a standalone code:

      import java.time.*;
      import java.time.format.*;
      import java.util.Arrays;
      import java.util.HashSet;

      import static java.time.temporal.ChronoField.*;
      import static org.testng.Assert.*;

      public class Test_resolverFields_selectOneDateResolveYD {

          public static void main(String[] args) {
              DateTimeFormatter base = new DateTimeFormatterBuilder()
                      .appendValue(YEAR).appendLiteral('-').appendValue(MONTH_OF_YEAR).appendLiteral('-')
                      .appendValue(DAY_OF_MONTH).appendLiteral('-').appendValue(DAY_OF_YEAR).toFormatter();
              DateTimeFormatter f = base.withResolverFields(YEAR, DAY_OF_YEAR);
              assertEquals(f.getResolverFields(), new HashSet<>(Arrays.asList(YEAR, DAY_OF_YEAR)));
              try {
                  base.parse("2012-6-30-321", LocalDate::from); // wrong month/day-of-month
                  fail();
              } catch (DateTimeException ex) {
                  // expected, fails as it produces two different dates
              }
              LocalDate parsed = f.parse("2012-6-30-321", LocalDate::from); // ignored month/day-of-month
              assertEquals(parsed, LocalDate.of(2012, 11, 16));

          }
      }


      With JDK8b88 the program prints:


      Exception in thread "main" java.lang.AssertionError: Lists differ at element [0]: Year != DayOfYear expected:<Year> but was:<DayOfYear>
      at org.testng.Assert.fail(Assert.java:84)
      at org.testng.Assert.failNotEquals(Assert.java:438)
      at org.testng.Assert.assertEquals(Assert.java:108)
      at org.testng.Assert.assertEquals(Assert.java:489)
      at org.testng.Assert.assertEquals(Assert.java:458)
      at Test_resolverFields_selectOneDateResolveYD.main(Test_resolverFields_selectOneDateResolveYD.java:16)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:491)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)




        Attachments

          Activity

            People

            • Assignee:
              rriggs Roger Riggs
              Reporter:
              dbessono Dmitry Bessonov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: