Skip to content

Commit d5af9dc

Browse files
jhoellerunknown
authored andcommitted
Polishing
1 parent 89db04e commit d5af9dc

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

spring-context/src/main/java/org/springframework/scheduling/support/PeriodicTrigger.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@
3131
* <emphasis>completion</emphasis> time). To measure the interval between the
3232
* scheduled <emphasis>start</emphasis> time of each execution instead, set the
3333
* 'fixedRate' property to {@code true}.
34-
* <p>
35-
* Note that the TaskScheduler interface already defines methods for scheduling
34+
*
35+
* <p>Note that the TaskScheduler interface already defines methods for scheduling
3636
* tasks at fixed-rate or with fixed-delay. Both also support an optional value
3737
* for the initial delay. Those methods should be used directly whenever
3838
* possible. The value of this Trigger implementation is that it can be used
@@ -68,7 +68,7 @@ public PeriodicTrigger(long period) {
6868
*/
6969
public PeriodicTrigger(long period, TimeUnit timeUnit) {
7070
Assert.isTrue(period >= 0, "period must not be negative");
71-
this.timeUnit = (timeUnit != null) ? timeUnit : TimeUnit.MILLISECONDS;
71+
this.timeUnit = (timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS);
7272
this.period = this.timeUnit.toMillis(period);
7373
}
7474

@@ -91,6 +91,7 @@ public void setFixedRate(boolean fixedRate) {
9191
this.fixedRate = fixedRate;
9292
}
9393

94+
9495
/**
9596
* Returns the time after which a task should run again.
9697
*/
@@ -104,6 +105,7 @@ else if (this.fixedRate) {
104105
return new Date(triggerContext.lastCompletionTime().getTime() + this.period);
105106
}
106107

108+
107109
@Override
108110
public boolean equals(Object obj) {
109111
if (this == obj) {
@@ -113,16 +115,12 @@ public boolean equals(Object obj) {
113115
return false;
114116
}
115117
PeriodicTrigger other = (PeriodicTrigger) obj;
116-
return this.fixedRate == other.fixedRate
117-
&& this.initialDelay == other.initialDelay
118-
&& this.period == other.period;
118+
return (this.fixedRate == other.fixedRate && this.initialDelay == other.initialDelay && this.period == other.period);
119119
}
120120

121121
@Override
122122
public int hashCode() {
123-
return (this.fixedRate ? 17 : 29) +
124-
(int) (37 * this.period) +
125-
(int) (41 * this.initialDelay);
123+
return (this.fixedRate ? 17 : 29) + (int) (37 * this.period) + (int) (41 * this.initialDelay);
126124
}
127125

128126
}

spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,11 +16,6 @@
1616

1717
package org.springframework.scheduling.concurrent;
1818

19-
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertNotNull;
21-
import static org.junit.Assert.assertNull;
22-
import static org.junit.Assert.assertTrue;
23-
2419
import java.util.Date;
2520
import java.util.concurrent.Callable;
2621
import java.util.concurrent.CountDownLatch;
@@ -29,13 +24,16 @@
2924
import java.util.concurrent.TimeUnit;
3025
import java.util.concurrent.atomic.AtomicInteger;
3126

27+
import org.junit.After;
3228
import org.junit.Before;
3329
import org.junit.Test;
3430

3531
import org.springframework.scheduling.Trigger;
3632
import org.springframework.scheduling.TriggerContext;
3733
import org.springframework.util.ErrorHandler;
3834

35+
import static org.junit.Assert.*;
36+
3937
/**
4038
* @author Mark Fisher
4139
* @since 3.0
@@ -44,7 +42,6 @@ public class ThreadPoolTaskSchedulerTests {
4442

4543
private static final String THREAD_NAME_PREFIX = "test-";
4644

47-
4845
private final ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
4946

5047

@@ -54,6 +51,11 @@ public void initScheduler() {
5451
scheduler.afterPropertiesSet();
5552
}
5653

54+
@After
55+
public void shutdownScheduler() {
56+
scheduler.destroy();
57+
}
58+
5759

5860
// test methods
5961

0 commit comments

Comments
 (0)