jira.codehaus.org

  • Log In Access more options
    • Online Help
    • 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)
  • castor
  • CASTOR-2044

The parseDuration(String) method does not respect the decimal place when converting the string representation of milliseconds into an integer/short.

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.1.2.1
  • Fix Version/s: 1.2
  • Component/s: XML
  • Labels:
    None
  • Environment:
    All
  • Patch Submitted:
    Yes

Description

ssue:
The parseDuration(String) method does not respect the decimal place when converting the string representation of milliseconds into an integer/short.
In cases where milliseconds are less than 100, the milliseconds are reported wrong.

Eg.
"0.001" milliseconds is wrongly reported as 100 milliseconds when getMilli() is called after parseDuration(String) "0.01" milliseconds is wrongly reported as 100 milliseconds when getMilli() is called after parseDuration(String) "1.001" milliseconds is wrongly reported as 1.1 seconds when getMilli() is called after parseDuration(String) "1.01" milliseconds is wrongly reported as 1.1 seconds when getMilli() is called after parseDuration(String)

Root Cause:
When the milliseconds are converted from a string to integer, the leading zero's after the decimal place are dropped.

Solution:
Prefix the string representation with a "1" prior to converting to integer and then drop the "1" prior to setting the milliseconds numeric value.

Recommendations:
This class should be refactored to perhaps use a float value to handle intermediate millisecond logic.
The setMilli() method does not need to accept a long as the max value should be 999. I think there is some confusion between get/setMilli and toLong() which is obvious by studing the code. An exception should be thrown if setMilli is supplied with anything > 999. Otherwise, additional logic needs to be added to ensure Y,D,H,M,S are updated accordingly also.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    Duration.java
    13/Jul/07 9:45 AM
    25 kB
    Shawn Crook
  2. Text File
    patch.c2044.20070911.test.txt
    11/Sep/07 8:51 AM
    15 kB
    Werner Guttmann
  3. Text File
    patch.c2044.20070911.txt
    11/Sep/07 8:34 AM
    3 kB
    Werner Guttmann
  4. Text File
    patch.c2044.20070911-002.txt
    11/Sep/07 9:09 AM
    4 kB
    Werner Guttmann

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Werner Guttmann added a comment - 13/Jul/07 4:32 PM

Shawn, can you please supply us with a 'unified diff' against SVN trunk ? Let us know if you need any help with this ....

Show
Werner Guttmann added a comment - 13/Jul/07 4:32 PM Shawn, can you please supply us with a 'unified diff' against SVN trunk ? Let us know if you need any help with this ....
Hide
Permalink
Werner Guttmann added a comment - 10/Sep/07 3:38 AM

Shawn ?

Show
Werner Guttmann added a comment - 10/Sep/07 3:38 AM Shawn ?
Hide
Permalink
Werner Guttmann added a comment - 11/Sep/07 8:34 AM

Unified diff against SVN trunk.

Show
Werner Guttmann added a comment - 11/Sep/07 8:34 AM Unified diff against SVN trunk.
Hide
Permalink
Werner Guttmann added a comment - 11/Sep/07 8:51 AM

JUnit test case relative to codegen.

Show
Werner Guttmann added a comment - 11/Sep/07 8:51 AM JUnit test case relative to codegen.
Hide
Permalink
Werner Guttmann added a comment - 11/Sep/07 8:52 AM

Funny enough, the test case fails on the assertions regarding the milliseconds.

Show
Werner Guttmann added a comment - 11/Sep/07 8:52 AM Funny enough, the test case fails on the assertions regarding the milliseconds.
Hide
Permalink
Werner Guttmann added a comment - 11/Sep/07 9:09 AM

Final patch for review.

Show
Werner Guttmann added a comment - 11/Sep/07 9:09 AM Final patch for review.
Hide
Permalink
Werner Guttmann added a comment - 11/Sep/07 9:10 AM

Had to patch DurationDescriptor as well to get things working ...

Show
Werner Guttmann added a comment - 11/Sep/07 9:10 AM Had to patch DurationDescriptor as well to get things working ...

People

  • Assignee:
    Werner Guttmann
    Reporter:
    Shawn Crook
Vote (0)
Watch (0)

Dates

  • Created:
    13/Jul/07 9:45 AM
    Updated:
    14/Mar/08 6:41 AM
    Resolved:
    11/Sep/07 9:36 AM

Time Tracking

Estimated:
2h
Original Estimate - 2 hours
Remaining:
2h
Remaining Estimate - 2 hours
Logged:
Not Specified
Time Spent - Not Specified
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.