Skip to content

Commit b8f091e

Browse files
committed
Merge branch '6.0.x'
2 parents 41f8b69 + 3c05679 commit b8f091e

File tree

5 files changed

+35
-35
lines changed

5 files changed

+35
-35
lines changed

spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,9 @@ public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
212212

213213
@Override
214214
public ScheduledFuture<?> schedule(Runnable task, Instant startTime) {
215-
Duration initialDelay = Duration.between(this.clock.instant(), startTime);
215+
Duration delay = Duration.between(this.clock.instant(), startTime);
216216
try {
217-
return this.scheduledExecutor.schedule(decorateTask(task, false),
218-
NANO.convert(initialDelay), NANO);
217+
return this.scheduledExecutor.schedule(decorateTask(task, false), NANO.convert(delay), NANO);
219218
}
220219
catch (RejectedExecutionException ex) {
221220
throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);

spring-context/src/main/java/org/springframework/scheduling/concurrent/ReschedulingRunnable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public ScheduledFuture<?> schedule() {
7979
if (this.scheduledExecutionTime == null) {
8080
return null;
8181
}
82-
Duration initialDelay = Duration.between(this.triggerContext.getClock().instant(), this.scheduledExecutionTime);
83-
this.currentFuture = this.executor.schedule(this, initialDelay.toNanos(), TimeUnit.NANOSECONDS);
82+
Duration delay = Duration.between(this.triggerContext.getClock().instant(), this.scheduledExecutionTime);
83+
this.currentFuture = this.executor.schedule(this, delay.toNanos(), TimeUnit.NANOSECONDS);
8484
return this;
8585
}
8686
}

spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,9 @@ public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
377377
@Override
378378
public ScheduledFuture<?> schedule(Runnable task, Instant startTime) {
379379
ScheduledExecutorService executor = getScheduledExecutor();
380-
Duration initialDelay = Duration.between(this.clock.instant(), startTime);
380+
Duration delay = Duration.between(this.clock.instant(), startTime);
381381
try {
382-
return executor.schedule(errorHandlingTask(task, false),
383-
NANO.convert(initialDelay), NANO);
382+
return executor.schedule(errorHandlingTask(task, false), NANO.convert(delay), NANO);
384383
}
385384
catch (RejectedExecutionException ex) {
386385
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);

spring-core/src/main/java/org/springframework/core/io/PathResource.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class PathResource extends AbstractResource implements WritableResource {
6262

6363

6464
/**
65-
* Create a new PathResource from a Path handle.
65+
* Create a new {@code PathResource} from a {@link Path} handle.
6666
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
6767
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
6868
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" &rarr; "C:/dir1/dir2"!
@@ -74,7 +74,7 @@ public PathResource(Path path) {
7474
}
7575

7676
/**
77-
* Create a new PathResource from a Path handle.
77+
* Create a new {@code PathResource} from a path string.
7878
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
7979
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
8080
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" &rarr; "C:/dir1/dir2"!
@@ -87,7 +87,7 @@ public PathResource(String path) {
8787
}
8888

8989
/**
90-
* Create a new PathResource from a Path handle.
90+
* Create a new {@code PathResource} from a {@link URI}.
9191
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
9292
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
9393
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" &rarr; "C:/dir1/dir2"!
@@ -128,7 +128,7 @@ public boolean isReadable() {
128128
}
129129

130130
/**
131-
* This implementation opens a InputStream for the underlying file.
131+
* This implementation opens an {@link InputStream} for the underlying file.
132132
* @see java.nio.file.spi.FileSystemProvider#newInputStream(Path, OpenOption...)
133133
*/
134134
@Override
@@ -174,7 +174,7 @@ public boolean isWritable() {
174174
}
175175

176176
/**
177-
* This implementation opens a OutputStream for the underlying file.
177+
* This implementation opens an {@link OutputStream} for the underlying file.
178178
* @see java.nio.file.spi.FileSystemProvider#newOutputStream(Path, OpenOption...)
179179
*/
180180
@Override
@@ -186,7 +186,7 @@ public OutputStream getOutputStream() throws IOException {
186186
}
187187

188188
/**
189-
* This implementation returns a URL for the underlying file.
189+
* This implementation returns a {@link URL} for the underlying file.
190190
* @see java.nio.file.Path#toUri()
191191
* @see java.net.URI#toURL()
192192
*/
@@ -196,7 +196,7 @@ public URL getURL() throws IOException {
196196
}
197197

198198
/**
199-
* This implementation returns a URI for the underlying file.
199+
* This implementation returns a {@link URI} for the underlying file.
200200
* @see java.nio.file.Path#toUri()
201201
*/
202202
@Override
@@ -213,7 +213,7 @@ public boolean isFile() {
213213
}
214214

215215
/**
216-
* This implementation returns the underlying File reference.
216+
* This implementation returns the underlying {@link File} reference.
217217
*/
218218
@Override
219219
public File getFile() throws IOException {
@@ -228,7 +228,7 @@ public File getFile() throws IOException {
228228
}
229229

230230
/**
231-
* This implementation opens a Channel for the underlying file.
231+
* This implementation opens a {@link ReadableByteChannel} for the underlying file.
232232
* @see Files#newByteChannel(Path, OpenOption...)
233233
*/
234234
@Override
@@ -242,7 +242,7 @@ public ReadableByteChannel readableChannel() throws IOException {
242242
}
243243

244244
/**
245-
* This implementation opens a Channel for the underlying file.
245+
* This implementation opens a {@link WritableByteChannel} for the underlying file.
246246
* @see Files#newByteChannel(Path, OpenOption...)
247247
*/
248248
@Override
@@ -259,7 +259,7 @@ public long contentLength() throws IOException {
259259
}
260260

261261
/**
262-
* This implementation returns the underlying File's timestamp.
262+
* This implementation returns the underlying file's timestamp.
263263
* @see java.nio.file.Files#getLastModifiedTime(Path, java.nio.file.LinkOption...)
264264
*/
265265
@Override
@@ -270,7 +270,7 @@ public long lastModified() throws IOException {
270270
}
271271

272272
/**
273-
* This implementation creates a PathResource, applying the given path
273+
* This implementation creates a {@link PathResource}, applying the given path
274274
* relative to the path of the underlying file of this resource descriptor.
275275
* @see java.nio.file.Path#resolve(String)
276276
*/
@@ -295,7 +295,7 @@ public String getDescription() {
295295

296296

297297
/**
298-
* This implementation compares the underlying Path references.
298+
* This implementation compares the underlying {@link Path} references.
299299
*/
300300
@Override
301301
public boolean equals(@Nullable Object obj) {

spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void fileIsReadable() {
142142
}
143143

144144
@Test
145-
void doesNotExistIsNotReadable() {
145+
void nonExistingFileIsNotReadable() {
146146
PathResource resource = new PathResource(NON_EXISTING_FILE);
147147
assertThat(resource.isReadable()).isFalse();
148148
}
@@ -157,7 +157,7 @@ void directoryIsNotReadable() {
157157
void getInputStream() throws IOException {
158158
PathResource resource = new PathResource(TEST_FILE);
159159
byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream());
160-
assertThat(bytes.length).isGreaterThan(0);
160+
assertThat(bytes).hasSizeGreaterThan(0);
161161
}
162162

163163
@Test
@@ -167,7 +167,7 @@ void getInputStreamForDir() throws IOException {
167167
}
168168

169169
@Test
170-
void getInputStreamDoesNotExist() throws IOException {
170+
void getInputStreamForNonExistingFile() throws IOException {
171171
PathResource resource = new PathResource(NON_EXISTING_FILE);
172172
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::getInputStream);
173173
}
@@ -260,24 +260,26 @@ void directoryIsNotWritable() {
260260

261261
@Test
262262
void equalsAndHashCode() {
263-
Resource mr1 = new PathResource(TEST_FILE);
264-
Resource mr2 = new PathResource(TEST_FILE);
265-
Resource mr3 = new PathResource(TEST_DIR);
266-
assertThat(mr1).isEqualTo(mr2);
267-
assertThat(mr1).isNotEqualTo(mr3);
268-
assertThat(mr1).hasSameHashCodeAs(mr2);
269-
assertThat(mr1).doesNotHaveSameHashCodeAs(mr3);
263+
Resource resource1 = new PathResource(TEST_FILE);
264+
Resource resource2 = new PathResource(TEST_FILE);
265+
Resource resource3 = new PathResource(TEST_DIR);
266+
assertThat(resource1).isEqualTo(resource1);
267+
assertThat(resource1).isEqualTo(resource2);
268+
assertThat(resource2).isEqualTo(resource1);
269+
assertThat(resource1).isNotEqualTo(resource3);
270+
assertThat(resource1).hasSameHashCodeAs(resource2);
271+
assertThat(resource1).doesNotHaveSameHashCodeAs(resource3);
270272
}
271273

272274
@Test
273-
void outputStream(@TempDir Path temporaryFolder) throws IOException {
275+
void getOutputStreamForExistingFile(@TempDir Path temporaryFolder) throws IOException {
274276
PathResource resource = new PathResource(temporaryFolder.resolve("test"));
275277
FileCopyUtils.copy("test".getBytes(StandardCharsets.UTF_8), resource.getOutputStream());
276278
assertThat(resource.contentLength()).isEqualTo(4L);
277279
}
278280

279281
@Test
280-
void doesNotExistOutputStream(@TempDir Path temporaryFolder) throws IOException {
282+
void getOutputStreamForNonExistingFile(@TempDir Path temporaryFolder) throws IOException {
281283
File file = temporaryFolder.resolve("test").toFile();
282284
file.delete();
283285
PathResource resource = new PathResource(file.toPath());
@@ -286,7 +288,7 @@ void doesNotExistOutputStream(@TempDir Path temporaryFolder) throws IOException
286288
}
287289

288290
@Test
289-
void directoryOutputStream() throws IOException {
291+
void getOutputStreamForDirectory() {
290292
PathResource resource = new PathResource(TEST_DIR);
291293
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::getOutputStream);
292294
}
@@ -314,7 +316,7 @@ void getReadableByteChannelForDir() throws IOException {
314316
}
315317

316318
@Test
317-
void getReadableByteChannelDoesNotExist() throws IOException {
319+
void getReadableByteChannelForNonExistingFile() throws IOException {
318320
PathResource resource = new PathResource(NON_EXISTING_FILE);
319321
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::readableChannel);
320322
}

0 commit comments

Comments
 (0)