Uploaded image for project: 'Flume'
  1. Flume
  2. FLUME-2556

TestBucketPath.testDateFormatHours fails intermittently

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.1
    • Fix Version/s: 1.6.0
    • Component/s: None
    • Labels:
      None

      Description

      TestBucketPath.testDateFormatHours sometimes results in the following error:

      org.junit.ComparisonFailure: expected:<Sat Jun 23 1[2]:00:00 2012> but was:<Sat Jun 23 1[9]:00:00 2012>
      at org.junit.Assert.assertEquals(Assert.java:125)
      at org.junit.Assert.assertEquals(Assert.java:147)
      at org.apache.flume.formatter.output.TestBucketPath.testDateFormatHours(TestBucketPath.java:63)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        Activity

        Hide
        lofbele1 Lenny Lofberg added a comment -

        Problem could be that SimpleDateFormat instances are cached in BucketPath.java and timezone is not always reset when a cached instance is retrieved.

        For example if JUnit runs testDateFormatTimeZone() before testDateFormatHours() (both use "%c" format) then timezone is set in the cached SimpleDateFormat instance for "%c" ("EEE MMM d HH:mm:ss yyyy") when testDateFormatHours() gets it from the cache.

        Maybe timezone should be reset in getSimpleDateFormat() or in BucketPath.java around line 320 if the provided value is null.

            SimpleDateFormat format = getSimpleDateFormat(formatString);
            if (timeZone != null) {
              format.setTimeZone(timeZone);
            }
        
        Show
        lofbele1 Lenny Lofberg added a comment - Problem could be that SimpleDateFormat instances are cached in BucketPath.java and timezone is not always reset when a cached instance is retrieved. For example if JUnit runs testDateFormatTimeZone() before testDateFormatHours() (both use "%c" format) then timezone is set in the cached SimpleDateFormat instance for "%c" ("EEE MMM d HH:mm:ss yyyy") when testDateFormatHours() gets it from the cache. Maybe timezone should be reset in getSimpleDateFormat() or in BucketPath.java around line 320 if the provided value is null. SimpleDateFormat format = getSimpleDateFormat(formatString); if (timeZone != null ) { format.setTimeZone(timeZone); }
        Hide
        jrufus Johny Rufus added a comment -

        Lenny Lofberg, nice catch, can you attach a patch, incorporating your suggested fix.

        Show
        jrufus Johny Rufus added a comment - Lenny Lofberg , nice catch, can you attach a patch, incorporating your suggested fix.
        Hide
        jrufus Johny Rufus added a comment -

        Attaching a patch with the suggested fix by resetting the timezone to the system default when its not provided and an additional test case that would test the caching scenario

        Show
        jrufus Johny Rufus added a comment - Attaching a patch with the suggested fix by resetting the timezone to the system default when its not provided and an additional test case that would test the caching scenario
        Hide
        hshreedharan Hari Shreedharan added a comment -

        +1. Running tests and committing.

        Show
        hshreedharan Hari Shreedharan added a comment - +1. Running tests and committing.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 84465664c21ed0a1261f015a010b94a98153c8d7 in flume's branch refs/heads/trunk from Hari Shreedharan
        [ https://git-wip-us.apache.org/repos/asf?p=flume.git;h=8446566 ]

        FLUME-2556. BucketWriter DateFormat test fails intermittently.

        (Johny Rufus via Hari)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 84465664c21ed0a1261f015a010b94a98153c8d7 in flume's branch refs/heads/trunk from Hari Shreedharan [ https://git-wip-us.apache.org/repos/asf?p=flume.git;h=8446566 ] FLUME-2556 . BucketWriter DateFormat test fails intermittently. (Johny Rufus via Hari)
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 159178aa6a38ecc116a504b9f09b8de667a25ba4 in flume's branch refs/heads/flume-1.6 from Hari Shreedharan
        [ https://git-wip-us.apache.org/repos/asf?p=flume.git;h=159178a ]

        FLUME-2556. BucketWriter DateFormat test fails intermittently.

        (Johny Rufus via Hari)

        Show
        jira-bot ASF subversion and git services added a comment - Commit 159178aa6a38ecc116a504b9f09b8de667a25ba4 in flume's branch refs/heads/flume-1.6 from Hari Shreedharan [ https://git-wip-us.apache.org/repos/asf?p=flume.git;h=159178a ] FLUME-2556 . BucketWriter DateFormat test fails intermittently. (Johny Rufus via Hari)
        Hide
        hshreedharan Hari Shreedharan added a comment -

        Committed! Thanks Johny and Lenny!

        Show
        hshreedharan Hari Shreedharan added a comment - Committed! Thanks Johny and Lenny!
        Hide
        hudson Hudson added a comment -

        UNSTABLE: Integrated in flume-trunk #705 (See https://builds.apache.org/job/flume-trunk/705/)
        FLUME-2556. BucketWriter DateFormat test fails intermittently. (hshreedharan: http://git-wip-us.apache.org/repos/asf/flume/repo?p=flume.git&a=commit&h=84465664c21ed0a1261f015a010b94a98153c8d7)

        • flume-ng-core/src/test/java/org/apache/flume/formatter/output/TestBucketPath.java
        • flume-ng-core/src/main/java/org/apache/flume/formatter/output/BucketPath.java
        Show
        hudson Hudson added a comment - UNSTABLE: Integrated in flume-trunk #705 (See https://builds.apache.org/job/flume-trunk/705/ ) FLUME-2556 . BucketWriter DateFormat test fails intermittently. (hshreedharan: http://git-wip-us.apache.org/repos/asf/flume/repo?p=flume.git&a=commit&h=84465664c21ed0a1261f015a010b94a98153c8d7 ) flume-ng-core/src/test/java/org/apache/flume/formatter/output/TestBucketPath.java flume-ng-core/src/main/java/org/apache/flume/formatter/output/BucketPath.java
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Flume-trunk-hbase-98 #62 (See https://builds.apache.org/job/Flume-trunk-hbase-98/62/)
        FLUME-2556. BucketWriter DateFormat test fails intermittently. (hshreedharan: http://git-wip-us.apache.org/repos/asf/flume/repo?p=flume.git&a=commit&h=84465664c21ed0a1261f015a010b94a98153c8d7)

        • flume-ng-core/src/test/java/org/apache/flume/formatter/output/TestBucketPath.java
        • flume-ng-core/src/main/java/org/apache/flume/formatter/output/BucketPath.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Flume-trunk-hbase-98 #62 (See https://builds.apache.org/job/Flume-trunk-hbase-98/62/ ) FLUME-2556 . BucketWriter DateFormat test fails intermittently. (hshreedharan: http://git-wip-us.apache.org/repos/asf/flume/repo?p=flume.git&a=commit&h=84465664c21ed0a1261f015a010b94a98153c8d7 ) flume-ng-core/src/test/java/org/apache/flume/formatter/output/TestBucketPath.java flume-ng-core/src/main/java/org/apache/flume/formatter/output/BucketPath.java

          People

          • Assignee:
            jrufus Johny Rufus
            Reporter:
            jrufus Johny Rufus
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development