Skip to content

Commit

Permalink
Negative schedule time now indicates immediate execution.
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd authored and akarnokd committed May 12, 2014
1 parent 50b618e commit 261dc38
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public boolean isUnsubscribed() {

@Override
public Subscription schedule(final Action0 action, long delayTime, TimeUnit unit) {
long delay = unit.toMillis(delayTime);
long delay = Math.max(0, unit.toMillis(delayTime));
assertThatTheDelayIsValidForTheSwingTimer(delay);
final BooleanSubscription s = BooleanSubscription.create();
class ExecuteOnceAction implements ActionListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ public void testInvalidDelayValues() {
final Worker inner = scheduler.createWorker();
final Action0 action = mock(Action0.class);

exception.expect(IllegalArgumentException.class);
inner.schedulePeriodically(action, -1L, 100L, TimeUnit.SECONDS);

exception.expect(IllegalArgumentException.class);
inner.schedulePeriodically(action, 100L, -1L, TimeUnit.SECONDS);

exception.expect(IllegalArgumentException.class);
Expand Down

0 comments on commit 261dc38

Please sign in to comment.