JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Use Agile By Default
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile Access more options (Alt+g)
  • Create Issue
  • Mule
  • MULE-4791

EventGroupTestCase.testCompareTo() fails intermittently

  • Agile Board
  • More Actions
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: 2.2.5 (EE only)
  • Fix Version/s: 2.2.6 (EE only)
  • Component/s: Build: Integration Tests, Core: Routing / Filters
  • Labels:
    None
  • User impact:
    Low
  • Similar Issues:
    None

Description

The test EventGroupTestCase.testCompareTo() fails intermittently because it depends on the fact that some time passes between the creation of one object and the next.

This is the affected code:

// when the groupId is not Comparable, the creation time is used as fallback
        g1 = new EventGroup(new Object());
        g2 = new EventGroup(new Object());
        // g1 is older (smaller) than g2
        assertTrue(g1.compareTo(g2) < 0);
        assertTrue(g2.compareTo(g1) > 0);

In order for the assertions to pass, there must be at least one nanosecond between the creation of g1 and g2. Sometimes this is not the case so the test fails. I suggest inserting a Thread.yield() call in the middle of the two cretions, like this:

// when the groupId is not Comparable, the creation time is used as fallback
        g1 = new EventGroup(new Object());
        Thread.yield(); // this makes sure that there is a time difference between
                        // the two EventGroup creations.
        g2 = new EventGroup(new Object());
        // g1 is older (smaller) than g2
        assertTrue(g1.compareTo(g2) < 0);
        assertTrue(g2.compareTo(g1) > 0);

Issue Links

relates to

Sub-task - The sub-task of the issue MULE-4592 EventGroup does not work with IBM JDK

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Transitions
  • Commits
  • Source
  • Builds
Hide
Permalink
Dirk Olmes added a comment - 16/Mar/10 12:14 AM

Edu, your analysis is spot on. This is already fixed in the 3.x sources, I added a small sleep between the two invocations. I'm not sure if the yield will help - this test runs single-threaded. The javadocs of Thread.yield() don't give me enough details to be sure that this is a good fix for the problem. Rather, port the fix from the 3.x tree back to 2.2.x.

Show
Dirk Olmes added a comment - 16/Mar/10 12:14 AM Edu, your analysis is spot on. This is already fixed in the 3.x sources, I added a small sleep between the two invocations. I'm not sure if the yield will help - this test runs single-threaded. The javadocs of Thread.yield() don't give me enough details to be sure that this is a good fix for the problem. Rather, port the fix from the 3.x tree back to 2.2.x.
Hide
Permalink
Edu Pereda added a comment - 16/Mar/10 06:58 AM

Ok, I will do that. I used Thread.yieald() because I thought there must always be another thread (at least the garbage collector one, for example), but to make sure, and for consistency, I will use what you suggested.

Show
Edu Pereda added a comment - 16/Mar/10 06:58 AM Ok, I will do that. I used Thread.yieald() because I thought there must always be another thread (at least the garbage collector one, for example), but to make sure, and for consistency, I will use what you suggested.
Hide
Permalink
Edu Pereda added a comment - 16/Mar/10 07:15 AM

This is the fisheye: http://fisheye.codehaus.org/changelog/mule/?cs=16850

Show
Edu Pereda added a comment - 16/Mar/10 07:15 AM This is the fisheye: http://fisheye.codehaus.org/changelog/mule/?cs=16850

People

  • Assignee:
    Edu Pereda
    Reporter:
    Edu Pereda
Vote (0)
Watch (0)

Dates

  • Created:
    15/Mar/10 05:14 PM
    Updated:
    16/Mar/10 08:12 AM
    Resolved:
    16/Mar/10 08:12 AM

Agile

  • View on Board
  • Atlassian JIRA (v5.0.7#734-sha1:8ad78a6)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for MuleForge. Try JIRA - bug tracking software for your team.