Mojo
  1. Mojo
  2. MOJO-1176

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

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: dashboard
    • Labels:
      None
    • Environment:
      Debian GNU/Linux (unstable), IBM JVM 1.4.2 SR11
    • Complexity:
      Intermediate
    • Number of attachments :
      0

      Description

      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.

        Activity

        Hide
        Duncan Doyle added a comment -

        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.

        Show
        Duncan Doyle added a comment - 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.
        Hide
        David Vicente added a comment -

        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

        Show
        David Vicente added a comment - 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
        Hide
        Duncan Doyle added a comment -

        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.

        Show
        Duncan Doyle added a comment - 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.
        Hide
        David Vicente added a comment -

        Corrected and released the July 21th 2008 as dashboard-maven-plugin-1.0-20080721.144534-21.jar

        Show
        David Vicente added a comment - Corrected and released the July 21th 2008 as dashboard-maven-plugin-1.0-20080721.144534-21.jar

          People

          • Assignee:
            David Vicente
            Reporter:
            Duncan Doyle
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: