Issue Details (XML | Word | Printable)

Key: MOJO-1176
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Blocker Blocker
Assignee: David Vicente
Reporter: Duncan Doyle
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Mojo

PeriodUtils.getDateFromPattern returns wrong Date for "Endof_thisweek" on IBM 1.4.2 JVM

Created: 14/Jul/08 09:41 AM   Updated: 21/Jul/08 10:51 AM
Component/s: dashboard
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Debian GNU/Linux (unstable), IBM JVM 1.4.2 SR11

Complexity: Intermediate


 Description  « Hide
This may sound rather strange, but I have an issue with the Dashboard plugin on an IBM 1.4.2 JVM on Linux. When I run the goal "dashboard" (after the "persist" goal) I get this error:

[ERROR] The graph Configuration (id = cobertura.currentweek) is wrong. startPeriod (Startof_thisweek = Mon Jul 14 00:00:00 CEST 2008) is not before the endPeriod (Endof_thisweek = Sun Jul 13 23:59:59 CEST 2008).
[ERROR] DashBoardHistoricReportMojo executeReport() failed.
org.apache.maven.reporting.MavenReportException: The maven-dashboard-config.xml is not valid. see error messages above or see the maven-dashboard-config.xsd file.
at org.codehaus.mojo.dashboard.report.plugin.DashBoardReportMojo.executeReport(DashBoardReportMojo.java:334)
at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:98)
at org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:73)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

This only seems to happen on Linux with the IBM JVM. The SUN JVM does work, the IBM JVM on Windows also works.

I have been playing around a bit with the PeriodUtils class (which determines the date) and found the following:

1) When I insert this line

"System.out.println("Calendar: " + cal.get(Calendar.YEAR) +", " + cal.get(Calendar.MONTH) + ", " + cal.get(Calendar.DAY_OF_MONTH) + ";" + cal.get(Calendar.DAY_OF_WEEK) +
cal.get(Calendar.HOUR) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND));"

before the "cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);" statement in the "ENDOF_THISWEEK" code path, the returned date is correct (how strange is that, it's just a System.out.println() and some 'get' statements on the Calendar object??????).

2) When I switch the statements :
cal.setTime(currentDate);
cal.setFirstDayOfWeek(Calendar.MONDAY);

so the statements are in this order:

cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.setTime(currentDate);

the correct date is displayed as well.

I have currently have NO explanation for this issue, or the solutions, but the dashboard plugin in its current state just doesn't work on an IBM JVM 1.4.2 on Linux.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Duncan Doyle added a comment - 16/Jul/08 10:46 AM
OK, checked it again today. I copied the 'getDateFromPattern' method into my own 'public static void main' class to ease testing. Today, it didn't give the wrong 'endof_thisweek' date. However ....... (imagine scary music here ) it gave the wrong 'startof_thisweek' date.

Start of this week: Mon Jul 21 00:00:00 CEST 2008
End of this week: Sun Jul 20 23:59:59 CEST 2008

I'm going to contact IBM on this. This is insane. The fix I proposed above (switching the 'setTime' and 'setFirstDayOfWeek' calls) also fixes the issue in this case.


David Vicente added a comment - 17/Jul/08 03:14 AM
Hi,

the same piece of code works fine under Windows OS with SUn or IBM jdk ?

If yes, i will correct it and make regression tests.

Keep me in touch

David


Duncan Doyle added a comment - 17/Jul/08 04:29 AM
Yes, it works fine in Windows with both Sun and IBM JDK.

Yesterday I tested the code on AIX as well and the bug is also present on our AIX system (IBM JDK 1.4.2 as well). I've written a test class which shows the bug. It is an extract of your code with some extra methods which show when the bug does not occur (i.e one with the debug statement and one with the switched lines of code). I've send this test class to our internal department which have direct contact with IBM support. I'll keep you posted on the outcome.

My advice would indeed be to switch the:

cal.setTime(currentDate);
cal.setFirstDayOfWeek(Calendar.MONDAY);

so the statements are in this order:

cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.setTime(currentDate);

This seems to fix the issue on both AIX and Linux.


David Vicente added a comment - 21/Jul/08 10:51 AM
Corrected and released the July 21th 2008 as dashboard-maven-plugin-1.0-20080721.144534-21.jar