[API Review] RT-27903: updateProgress should be more generous with illegal values

Richard Bair richard.bair at oracle.com
Fri Jan 25 10:55:44 PST 2013


I did this one backwards -- as I pushed the fix I realized this is actually a change in specification and should have been sent to this list. The (now old) code was throwing illegal argument exceptions if you passed a workDone > totalWork, or if it was < -1, etc. A related issue http://javafx-jira.kenai.com/browse/RT-21930 pointed out that there were some illegal cases that weren't well handled, such as -.5.

While working on other Service bugs, I wrote a test implementation where the workDone was sometimes barely larger than the totalWork -- maybe due to a rounding error in Doubles, or due to a one-past error in my code. It ended up throwing an exception from updateProgress and then causing the UI to get "stuck" because I was being lazy and not doing error handling in my Task.

instead, updateProgress really doesn't need to be so bossy. If i give it NaN, or Infinity, or -.5, or -10, it ought to just treat them all as -1 and be happy about it. If i give it a workDone larger than totalWork, it ought to just clamp workDone to totalWork and be happy about it.

http://javafx-jira.kenai.com/browse/RT-27903


More information about the openjfx-dev mailing list