Skip to content

Commit 5d4c284

Browse files
committed
Polishing
1 parent a3daee6 commit 5d4c284

File tree

8 files changed

+64
-52
lines changed

8 files changed

+64
-52
lines changed

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

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

207207
@Override
208208
public ScheduledFuture<?> schedule(Runnable task, Date startTime) {
209-
long initialDelay = startTime.getTime() - this.clock.millis();
209+
long delay = startTime.getTime() - this.clock.millis();
210210
try {
211-
return this.scheduledExecutor.schedule(decorateTask(task, false), initialDelay, TimeUnit.MILLISECONDS);
211+
return this.scheduledExecutor.schedule(decorateTask(task, false), delay, TimeUnit.MILLISECONDS);
212212
}
213213
catch (RejectedExecutionException ex) {
214214
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -78,8 +78,8 @@ public ScheduledFuture<?> schedule() {
7878
if (this.scheduledExecutionTime == null) {
7979
return null;
8080
}
81-
long initialDelay = this.scheduledExecutionTime.getTime() - this.triggerContext.getClock().millis();
82-
this.currentFuture = this.executor.schedule(this, initialDelay, TimeUnit.MILLISECONDS);
81+
long delay = this.scheduledExecutionTime.getTime() - this.triggerContext.getClock().millis();
82+
this.currentFuture = this.executor.schedule(this, delay, TimeUnit.MILLISECONDS);
8383
return this;
8484
}
8585
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -380,9 +380,9 @@ public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
380380
@Override
381381
public ScheduledFuture<?> schedule(Runnable task, Date startTime) {
382382
ScheduledExecutorService executor = getScheduledExecutor();
383-
long initialDelay = startTime.getTime() - this.clock.millis();
383+
long delay = startTime.getTime() - this.clock.millis();
384384
try {
385-
return executor.schedule(errorHandlingTask(task, false), initialDelay, TimeUnit.MILLISECONDS);
385+
return executor.schedule(errorHandlingTask(task, false), delay, TimeUnit.MILLISECONDS);
386386
}
387387
catch (RejectedExecutionException ex) {
388388
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);

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

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -33,13 +33,15 @@
3333
*
3434
* <p>Supports resolution as {@code java.io.File} if the class path
3535
* resource resides in the file system, but not for resources in a JAR.
36-
* Always supports resolution as URL.
36+
* Always supports resolution as {@code java.net.URL}.
3737
*
3838
* @author Juergen Hoeller
3939
* @author Sam Brannen
4040
* @since 28.12.2003
4141
* @see ClassLoader#getResourceAsStream(String)
42+
* @see ClassLoader#getResource(String)
4243
* @see Class#getResourceAsStream(String)
44+
* @see Class#getResource(String)
4345
*/
4446
public class ClassPathResource extends AbstractFileResolvingResource {
4547

@@ -124,7 +126,7 @@ public final String getPath() {
124126
}
125127

126128
/**
127-
* Return the ClassLoader that this resource will be obtained from.
129+
* Return the {@link ClassLoader} that this resource will be obtained from.
128130
*/
129131
@Nullable
130132
public final ClassLoader getClassLoader() {
@@ -134,8 +136,8 @@ public final ClassLoader getClassLoader() {
134136

135137
/**
136138
* This implementation checks for the resolution of a resource URL.
137-
* @see java.lang.ClassLoader#getResource(String)
138-
* @see java.lang.Class#getResource(String)
139+
* @see ClassLoader#getResource(String)
140+
* @see Class#getResource(String)
139141
*/
140142
@Override
141143
public boolean exists() {
@@ -145,8 +147,8 @@ public boolean exists() {
145147
/**
146148
* This implementation checks for the resolution of a resource URL upfront,
147149
* then proceeding with {@link AbstractFileResolvingResource}'s length check.
148-
* @see java.lang.ClassLoader#getResource(String)
149-
* @see java.lang.Class#getResource(String)
150+
* @see ClassLoader#getResource(String)
151+
* @see Class#getResource(String)
150152
*/
151153
@Override
152154
public boolean isReadable() {
@@ -179,9 +181,11 @@ else if (this.classLoader != null) {
179181
}
180182

181183
/**
182-
* This implementation opens an InputStream for the given class path resource.
183-
* @see java.lang.ClassLoader#getResourceAsStream(String)
184-
* @see java.lang.Class#getResourceAsStream(String)
184+
* This implementation opens an {@link InputStream} for the underlying class
185+
* path resource, if available.
186+
* @see ClassLoader#getResourceAsStream(String)
187+
* @see Class#getResourceAsStream(String)
188+
* @see ClassLoader#getSystemResourceAsStream(String)
185189
*/
186190
@Override
187191
public InputStream getInputStream() throws IOException {
@@ -204,8 +208,8 @@ else if (this.classLoader != null) {
204208
/**
205209
* This implementation returns a URL for the underlying class path resource,
206210
* if available.
207-
* @see java.lang.ClassLoader#getResource(String)
208-
* @see java.lang.Class#getResource(String)
211+
* @see ClassLoader#getResource(String)
212+
* @see Class#getResource(String)
209213
*/
210214
@Override
211215
public URL getURL() throws IOException {
@@ -217,9 +221,9 @@ public URL getURL() throws IOException {
217221
}
218222

219223
/**
220-
* This implementation creates a ClassPathResource, applying the given path
221-
* relative to the path of the underlying resource of this descriptor.
222-
* @see org.springframework.util.StringUtils#applyRelativePath(String, String)
224+
* This implementation creates a {@code ClassPathResource}, applying the given
225+
* path relative to the path used to create this descriptor.
226+
* @see StringUtils#applyRelativePath(String, String)
223227
*/
224228
@Override
225229
public Resource createRelative(String relativePath) {
@@ -231,7 +235,7 @@ public Resource createRelative(String relativePath) {
231235
/**
232236
* This implementation returns the name of the file that this class path
233237
* resource refers to.
234-
* @see org.springframework.util.StringUtils#getFilename(String)
238+
* @see StringUtils#getFilename(String)
235239
*/
236240
@Override
237241
@Nullable
@@ -277,8 +281,7 @@ public boolean equals(@Nullable Object other) {
277281
}
278282

279283
/**
280-
* This implementation returns the hash code of the underlying
281-
* class path location.
284+
* This implementation returns the hash code of the underlying class path location.
282285
*/
283286
@Override
284287
public int hashCode() {

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -158,6 +158,7 @@ public final String getPath() {
158158
/**
159159
* This implementation returns whether the underlying file exists.
160160
* @see java.io.File#exists()
161+
* @see java.nio.file.Files#exists(Path, java.nio.file.LinkOption...)
161162
*/
162163
@Override
163164
public boolean exists() {
@@ -169,6 +170,8 @@ public boolean exists() {
169170
* (and corresponds to an actual file with content, not to a directory).
170171
* @see java.io.File#canRead()
171172
* @see java.io.File#isDirectory()
173+
* @see java.nio.file.Files#isReadable(Path)
174+
* @see java.nio.file.Files#isDirectory(Path, java.nio.file.LinkOption...)
172175
*/
173176
@Override
174177
public boolean isReadable() {
@@ -177,8 +180,8 @@ public boolean isReadable() {
177180
}
178181

179182
/**
180-
* This implementation opens a NIO file stream for the underlying file.
181-
* @see java.io.FileInputStream
183+
* This implementation opens an NIO file stream for the underlying file.
184+
* @see java.nio.file.Files#newInputStream(Path, java.nio.file.OpenOption...)
182185
*/
183186
@Override
184187
public InputStream getInputStream() throws IOException {
@@ -195,6 +198,8 @@ public InputStream getInputStream() throws IOException {
195198
* (and corresponds to an actual file with content, not to a directory).
196199
* @see java.io.File#canWrite()
197200
* @see java.io.File#isDirectory()
201+
* @see java.nio.file.Files#isWritable(Path)
202+
* @see java.nio.file.Files#isDirectory(Path, java.nio.file.LinkOption...)
198203
*/
199204
@Override
200205
public boolean isWritable() {
@@ -204,7 +209,7 @@ public boolean isWritable() {
204209

205210
/**
206211
* This implementation opens a FileOutputStream for the underlying file.
207-
* @see java.io.FileOutputStream
212+
* @see java.nio.file.Files#newOutputStream(Path, java.nio.file.OpenOption...)
208213
*/
209214
@Override
210215
public OutputStream getOutputStream() throws IOException {
@@ -214,6 +219,7 @@ public OutputStream getOutputStream() throws IOException {
214219
/**
215220
* This implementation returns a URL for the underlying file.
216221
* @see java.io.File#toURI()
222+
* @see java.nio.file.Path#toUri()
217223
*/
218224
@Override
219225
public URL getURL() throws IOException {
@@ -223,6 +229,7 @@ public URL getURL() throws IOException {
223229
/**
224230
* This implementation returns a URI for the underlying file.
225231
* @see java.io.File#toURI()
232+
* @see java.nio.file.Path#toUri()
226233
*/
227234
@Override
228235
public URI getURI() throws IOException {
@@ -324,6 +331,7 @@ public Resource createRelative(String relativePath) {
324331
/**
325332
* This implementation returns the name of the file.
326333
* @see java.io.File#getName()
334+
* @see java.nio.file.Path#getFileName()
327335
*/
328336
@Override
329337
public String getFilename() {
@@ -334,6 +342,7 @@ public String getFilename() {
334342
* This implementation returns a description that includes the absolute
335343
* path of the file.
336344
* @see java.io.File#getAbsolutePath()
345+
* @see java.nio.file.Path#toAbsolutePath()
337346
*/
338347
@Override
339348
public String getDescription() {
@@ -342,7 +351,7 @@ public String getDescription() {
342351

343352

344353
/**
345-
* This implementation compares the underlying File references.
354+
* This implementation compares the underlying file paths.
346355
*/
347356
@Override
348357
public boolean equals(@Nullable Object other) {
@@ -351,7 +360,7 @@ public boolean equals(@Nullable Object other) {
351360
}
352361

353362
/**
354-
* This implementation returns the hash code of the underlying File reference.
363+
* This implementation returns the hash code of the underlying file path.
355364
*/
356365
@Override
357366
public int hashCode() {

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2023 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.
@@ -61,7 +61,7 @@ public class PathResource extends AbstractResource implements WritableResource {
6161

6262

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

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

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

129129
/**
130-
* This implementation opens a InputStream for the underlying file.
130+
* This implementation opens an {@link InputStream} for the underlying file.
131131
* @see java.nio.file.spi.FileSystemProvider#newInputStream(Path, OpenOption...)
132132
*/
133133
@Override
@@ -153,7 +153,7 @@ public boolean isWritable() {
153153
}
154154

155155
/**
156-
* This implementation opens a OutputStream for the underlying file.
156+
* This implementation opens an {@link OutputStream} for the underlying file.
157157
* @see java.nio.file.spi.FileSystemProvider#newOutputStream(Path, OpenOption...)
158158
*/
159159
@Override
@@ -165,7 +165,7 @@ public OutputStream getOutputStream() throws IOException {
165165
}
166166

167167
/**
168-
* This implementation returns a URL for the underlying file.
168+
* This implementation returns a {@link URL} for the underlying file.
169169
* @see java.nio.file.Path#toUri()
170170
* @see java.net.URI#toURL()
171171
*/
@@ -175,7 +175,7 @@ public URL getURL() throws IOException {
175175
}
176176

177177
/**
178-
* This implementation returns a URI for the underlying file.
178+
* This implementation returns a {@link URI} for the underlying file.
179179
* @see java.nio.file.Path#toUri()
180180
*/
181181
@Override
@@ -192,7 +192,7 @@ public boolean isFile() {
192192
}
193193

194194
/**
195-
* This implementation returns the underlying File reference.
195+
* This implementation returns the underlying {@link File} reference.
196196
*/
197197
@Override
198198
public File getFile() throws IOException {
@@ -207,7 +207,7 @@ public File getFile() throws IOException {
207207
}
208208

209209
/**
210-
* This implementation opens a Channel for the underlying file.
210+
* This implementation opens a {@link ReadableByteChannel} for the underlying file.
211211
* @see Files#newByteChannel(Path, OpenOption...)
212212
*/
213213
@Override
@@ -221,7 +221,7 @@ public ReadableByteChannel readableChannel() throws IOException {
221221
}
222222

223223
/**
224-
* This implementation opens a Channel for the underlying file.
224+
* This implementation opens a {@link WritableByteChannel} for the underlying file.
225225
* @see Files#newByteChannel(Path, OpenOption...)
226226
*/
227227
@Override
@@ -238,7 +238,7 @@ public long contentLength() throws IOException {
238238
}
239239

240240
/**
241-
* This implementation returns the underlying File's timestamp.
241+
* This implementation returns the underlying file's timestamp.
242242
* @see java.nio.file.Files#getLastModifiedTime(Path, java.nio.file.LinkOption...)
243243
*/
244244
@Override
@@ -249,7 +249,7 @@ public long lastModified() throws IOException {
249249
}
250250

251251
/**
252-
* This implementation creates a PathResource, applying the given path
252+
* This implementation creates a {@link PathResource}, applying the given path
253253
* relative to the path of the underlying file of this resource descriptor.
254254
* @see java.nio.file.Path#resolve(String)
255255
*/
@@ -274,7 +274,7 @@ public String getDescription() {
274274

275275

276276
/**
277-
* This implementation compares the underlying Path references.
277+
* This implementation compares the underlying {@link Path} references.
278278
*/
279279
@Override
280280
public boolean equals(@Nullable Object other) {
@@ -283,7 +283,7 @@ public boolean equals(@Nullable Object other) {
283283
}
284284

285285
/**
286-
* This implementation returns the hash code of the underlying Path reference.
286+
* This implementation returns the hash code of the underlying {@link Path} reference.
287287
*/
288288
@Override
289289
public int hashCode() {

0 commit comments

Comments
 (0)