JodaOrg / joda-time

Joda-Time is the widely used replacement for the Java date and time classes prior to Java SE 8.
http://www.joda.org/joda-time/
Apache License 2.0
4.98k stars 986 forks source link

testPropertyGetMonthOfYear failures with CLDR 39 #674

Closed cushon closed 1 year ago

cushon commented 2 years ago

Key information

Problem description

When running on JDK 17, several Joda tests fail due to a change to the JDK's CLDR data: JDK-8265308

Test case

$ java -fullversion
openjdk full version "17.0.2+8-86"
$ mvn clean test
...
[ERROR] Tests run: 4232, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 2.129 s <<< FAILURE! - in org.joda.time.TestAllPackages
[ERROR] testPropertyGetMonthOfYear(org.joda.time.TestDateTime_Properties)  Time elapsed: 0.004 s  <<< FAILURE!
junit.framework.AssertionFailedError: expected:<3> but was:<4>
        at junit.framework.Assert.fail(Assert.java:47)
        at junit.framework.Assert.failNotEquals(Assert.java:280)
        at junit.framework.Assert.assertEquals(Assert.java:64)
        at junit.framework.Assert.assertEquals(Assert.java:198)
        at junit.framework.Assert.assertEquals(Assert.java:204)
        at org.joda.time.TestDateTime_Properties.testPropertyGetMonthOfYear(TestDateTime_Properties.java:361)

[ERROR] testPropertyGetMonthOfYear(org.joda.time.TestMutableDateTime_Properties)  Time elapsed: 0 s  <<< FAILURE!
junit.framework.AssertionFailedError: expected:<3> but was:<4>
        at junit.framework.Assert.fail(Assert.java:47)
        at junit.framework.Assert.failNotEquals(Assert.java:280)
        at junit.framework.Assert.assertEquals(Assert.java:64)
        at junit.framework.Assert.assertEquals(Assert.java:198)
        at junit.framework.Assert.assertEquals(Assert.java:204)
        at org.joda.time.TestMutableDateTime_Properties.testPropertyGetMonthOfYear(TestMutableDateTime_Properties.java:247)

[ERROR] testPropertyGetMonthOfYear(org.joda.time.TestDateMidnight_Properties)  Time elapsed: 0 s  <<< FAILURE!
junit.framework.AssertionFailedError: expected:<3> but was:<4>
        at junit.framework.Assert.fail(Assert.java:47)
        at junit.framework.Assert.failNotEquals(Assert.java:280)
        at junit.framework.Assert.assertEquals(Assert.java:64)
        at junit.framework.Assert.assertEquals(Assert.java:198)
        at junit.framework.Assert.assertEquals(Assert.java:204)
        at org.joda.time.TestDateMidnight_Properties.testPropertyGetMonthOfYear(TestDateMidnight_Properties.java:238)

[ERROR] testPropertyGetMonthOfYear(org.joda.time.TestMonthDay_Properties)  Time elapsed: 0.001 s  <<< FAILURE!
junit.framework.ComparisonFailure: expected:<Sep[]> but was:<Sep[t]>
        at junit.framework.Assert.assertEquals(Assert.java:81)
        at junit.framework.Assert.assertEquals(Assert.java:87)
        at org.joda.time.TestMonthDay_Properties.testPropertyGetMonthOfYear(TestMonthDay_Properties.java:93)

Since the JDK 17 javac doesn't support -source 5 -target 5 I had to update the build to use Java 8, but compiling the tests as Java 5 and running on JDK 17 would reproduce the same issue:

git diff
diff --git a/pom.xml b/pom.xml
index 486dd702..d6e60402 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1069,8 +1069,8 @@
     <nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
     <!-- Properties for maven-compiler-plugin -->
     <maven.compiler.compilerVersion>1.5</maven.compiler.compilerVersion>
-    <maven.compiler.source>1.5</maven.compiler.source>
-    <maven.compiler.target>1.5</maven.compiler.target>
+    <maven.compiler.source>8</maven.compiler.source>
+    <maven.compiler.target>8</maven.compiler.target>
     <maven.compiler.fork>true</maven.compiler.fork>
     <maven.compiler.verbose>false</maven.compiler.verbose>
     <maven.compiler.optimize>true</maven.compiler.optimize>