[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: RFR: 8327007: javax/swing/JSpinner/8008657/bug8008657.java fails
From:       Phil Race <prr () openjdk ! org>
Date:       2024-02-29 20:37:53
Message-ID: IwVbNBm2m7vPuxL2Jr1_7yUZJ3cUT7CxRnjMqZKgNY8=.9a12e5f6-3a7a-4a4e-8870-16a321fd7240 () github ! com
[Download RAW message or body]

On Thu, 29 Feb 2024 09:34:05 GMT, Prasanta Sadhukhan <psadhukhan@openjdk.org> wrote:

> Test failed with the exception java.lang.IllegalArgumentException: (start <= value \
> <= end) with no history of failing till date. Investigation shows SpinnerDateModel \
> constructor condition is not satisfied because It seems it's a leap year problem \
> that is being manifested.. 
> As per test,
> initDate Thu Feb 29 13:49:08 IST 2024 [ obtained by calendar.getTime();]
> earliestDate Tue Feb 28 13:49:08 IST 2023 [obtained by calendar.add(Calendar.YEAR, \
> -1);] latestDate Wed Feb 28 13:49:08 IST 2024 [obtained by \
> calendar.add(Calendar.YEAR, 1);] 
> Now, as per SpinnerDateModel constructor
> earliestDate <= initDate condition is satisfied
> but
> latestDate >= initDate is not
> so [start <= value <= \
> end](https://github.com/openjdk/jdk/blob/998d0baab0fd051c38d9fd6021628eb863b80554/src/java.desktop/share/classes/javax/swing/SpinnerDateModel.java#L185) \
> condition fails 
> Not sure it anything can be done in Calendar class for this but fix is done in test \
> taking leapyear into account so that we add a day if it's a leapyear when we \
> consecutively do Calendar.add(YEAR, -1) and Calendar.add(YEAR,1) on leapyear date \
> of 29Feb

Surely this just needs a one line fix
<pre>
diff --git a/test/jdk/javax/swing/JSpinner/8008657/bug8008657.java \
b/test/jdk/javax/swing/JSpinner/8008657/bug8008657.java index \
                cbeb0c185bb..49918278e34 100644
--- a/test/jdk/javax/swing/JSpinner/8008657/bug8008657.java
+++ b/test/jdk/javax/swing/JSpinner/8008657/bug8008657.java
@@ -137,6 +137,7 @@ static void createDateSpinner() {
         calendar.add(Calendar.YEAR, -1);
         Date earliestDate = calendar.getTime();
         calendar.add(Calendar.YEAR, 1);
+        calendar.add(Calendar.DAY_OF_MONTH, 1);
         Date latestDate = calendar.getTime();
         SpinnerModel dateModel = new SpinnerDateModel(initDate,
                 earliestDate,
</pre>

-------------

PR Comment: https://git.openjdk.org/jdk/pull/18054#issuecomment-1971912446


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic