-
Enhancement
-
Resolution: Fixed
-
P4
-
None
The updateProgress methods of Task are spec'd such that the workDone must be less than or equal to max, or an IllegalArgumentException is thrown. This is sometimes a pain. The following Service would sometimes throw an exception based on timing where the "delta" ended up being 1 more than max:
final Service<Void> service = new Service<Void>() {
final Service<Void> svc = this;
@Override protected Task<Void> createTask() {
return new Task<Void>() {
@Override protected Void call() throws Exception {
long millis = 1000;
long start = System.currentTimeMillis();
long delta = 0;
while (delta < millis) {
delta = System.currentTimeMillis() - start;
Thread.sleep(1);
updateProgress(delta, millis);
}
return null;
}
};
}
};
Instead, lets just spec that a call to updateProgress where workDown > max will be clamped to max.
final Service<Void> service = new Service<Void>() {
final Service<Void> svc = this;
@Override protected Task<Void> createTask() {
return new Task<Void>() {
@Override protected Void call() throws Exception {
long millis = 1000;
long start = System.currentTimeMillis();
long delta = 0;
while (delta < millis) {
delta = System.currentTimeMillis() - start;
Thread.sleep(1);
updateProgress(delta, millis);
}
return null;
}
};
}
};
Instead, lets just spec that a call to updateProgress where workDown > max will be clamped to max.
- relates to
-
JDK-8102152 RT-19645 introduced updatedProgress with double parameters but does not correctly checks parameters for valid double input
-
- Resolved
-