Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Jul 4, 2023
1 parent a3daee6 commit 5d4c284
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {

@Override
public ScheduledFuture<?> schedule(Runnable task, Date startTime) {
long initialDelay = startTime.getTime() - this.clock.millis();
long delay = startTime.getTime() - this.clock.millis();
try {
return this.scheduledExecutor.schedule(decorateTask(task, false), initialDelay, TimeUnit.MILLISECONDS);
return this.scheduledExecutor.schedule(decorateTask(task, false), delay, TimeUnit.MILLISECONDS);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -78,8 +78,8 @@ public ScheduledFuture<?> schedule() {
if (this.scheduledExecutionTime == null) {
return null;
}
long initialDelay = this.scheduledExecutionTime.getTime() - this.triggerContext.getClock().millis();
this.currentFuture = this.executor.schedule(this, initialDelay, TimeUnit.MILLISECONDS);
long delay = this.scheduledExecutionTime.getTime() - this.triggerContext.getClock().millis();
this.currentFuture = this.executor.schedule(this, delay, TimeUnit.MILLISECONDS);
return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -380,9 +380,9 @@ public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
@Override
public ScheduledFuture<?> schedule(Runnable task, Date startTime) {
ScheduledExecutorService executor = getScheduledExecutor();
long initialDelay = startTime.getTime() - this.clock.millis();
long delay = startTime.getTime() - this.clock.millis();
try {
return executor.schedule(errorHandlingTask(task, false), initialDelay, TimeUnit.MILLISECONDS);
return executor.schedule(errorHandlingTask(task, false), delay, TimeUnit.MILLISECONDS);
}
catch (RejectedExecutionException ex) {
throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,13 +33,15 @@
*
* <p>Supports resolution as {@code java.io.File} if the class path
* resource resides in the file system, but not for resources in a JAR.
* Always supports resolution as URL.
* Always supports resolution as {@code java.net.URL}.
*
* @author Juergen Hoeller
* @author Sam Brannen
* @since 28.12.2003
* @see ClassLoader#getResourceAsStream(String)
* @see ClassLoader#getResource(String)
* @see Class#getResourceAsStream(String)
* @see Class#getResource(String)
*/
public class ClassPathResource extends AbstractFileResolvingResource {

Expand Down Expand Up @@ -124,7 +126,7 @@ public final String getPath() {
}

/**
* Return the ClassLoader that this resource will be obtained from.
* Return the {@link ClassLoader} that this resource will be obtained from.
*/
@Nullable
public final ClassLoader getClassLoader() {
Expand All @@ -134,8 +136,8 @@ public final ClassLoader getClassLoader() {

/**
* This implementation checks for the resolution of a resource URL.
* @see java.lang.ClassLoader#getResource(String)
* @see java.lang.Class#getResource(String)
* @see ClassLoader#getResource(String)
* @see Class#getResource(String)
*/
@Override
public boolean exists() {
Expand All @@ -145,8 +147,8 @@ public boolean exists() {
/**
* This implementation checks for the resolution of a resource URL upfront,
* then proceeding with {@link AbstractFileResolvingResource}'s length check.
* @see java.lang.ClassLoader#getResource(String)
* @see java.lang.Class#getResource(String)
* @see ClassLoader#getResource(String)
* @see Class#getResource(String)
*/
@Override
public boolean isReadable() {
Expand Down Expand Up @@ -179,9 +181,11 @@ else if (this.classLoader != null) {
}

/**
* This implementation opens an InputStream for the given class path resource.
* @see java.lang.ClassLoader#getResourceAsStream(String)
* @see java.lang.Class#getResourceAsStream(String)
* This implementation opens an {@link InputStream} for the underlying class
* path resource, if available.
* @see ClassLoader#getResourceAsStream(String)
* @see Class#getResourceAsStream(String)
* @see ClassLoader#getSystemResourceAsStream(String)
*/
@Override
public InputStream getInputStream() throws IOException {
Expand All @@ -204,8 +208,8 @@ else if (this.classLoader != null) {
/**
* This implementation returns a URL for the underlying class path resource,
* if available.
* @see java.lang.ClassLoader#getResource(String)
* @see java.lang.Class#getResource(String)
* @see ClassLoader#getResource(String)
* @see Class#getResource(String)
*/
@Override
public URL getURL() throws IOException {
Expand All @@ -217,9 +221,9 @@ public URL getURL() throws IOException {
}

/**
* This implementation creates a ClassPathResource, applying the given path
* relative to the path of the underlying resource of this descriptor.
* @see org.springframework.util.StringUtils#applyRelativePath(String, String)
* This implementation creates a {@code ClassPathResource}, applying the given
* path relative to the path used to create this descriptor.
* @see StringUtils#applyRelativePath(String, String)
*/
@Override
public Resource createRelative(String relativePath) {
Expand All @@ -231,7 +235,7 @@ public Resource createRelative(String relativePath) {
/**
* This implementation returns the name of the file that this class path
* resource refers to.
* @see org.springframework.util.StringUtils#getFilename(String)
* @see StringUtils#getFilename(String)
*/
@Override
@Nullable
Expand Down Expand Up @@ -277,8 +281,7 @@ public boolean equals(@Nullable Object other) {
}

/**
* This implementation returns the hash code of the underlying
* class path location.
* This implementation returns the hash code of the underlying class path location.
*/
@Override
public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -158,6 +158,7 @@ public final String getPath() {
/**
* This implementation returns whether the underlying file exists.
* @see java.io.File#exists()
* @see java.nio.file.Files#exists(Path, java.nio.file.LinkOption...)
*/
@Override
public boolean exists() {
Expand All @@ -169,6 +170,8 @@ public boolean exists() {
* (and corresponds to an actual file with content, not to a directory).
* @see java.io.File#canRead()
* @see java.io.File#isDirectory()
* @see java.nio.file.Files#isReadable(Path)
* @see java.nio.file.Files#isDirectory(Path, java.nio.file.LinkOption...)
*/
@Override
public boolean isReadable() {
Expand All @@ -177,8 +180,8 @@ public boolean isReadable() {
}

/**
* This implementation opens a NIO file stream for the underlying file.
* @see java.io.FileInputStream
* This implementation opens an NIO file stream for the underlying file.
* @see java.nio.file.Files#newInputStream(Path, java.nio.file.OpenOption...)
*/
@Override
public InputStream getInputStream() throws IOException {
Expand All @@ -195,6 +198,8 @@ public InputStream getInputStream() throws IOException {
* (and corresponds to an actual file with content, not to a directory).
* @see java.io.File#canWrite()
* @see java.io.File#isDirectory()
* @see java.nio.file.Files#isWritable(Path)
* @see java.nio.file.Files#isDirectory(Path, java.nio.file.LinkOption...)
*/
@Override
public boolean isWritable() {
Expand All @@ -204,7 +209,7 @@ public boolean isWritable() {

/**
* This implementation opens a FileOutputStream for the underlying file.
* @see java.io.FileOutputStream
* @see java.nio.file.Files#newOutputStream(Path, java.nio.file.OpenOption...)
*/
@Override
public OutputStream getOutputStream() throws IOException {
Expand All @@ -214,6 +219,7 @@ public OutputStream getOutputStream() throws IOException {
/**
* This implementation returns a URL for the underlying file.
* @see java.io.File#toURI()
* @see java.nio.file.Path#toUri()
*/
@Override
public URL getURL() throws IOException {
Expand All @@ -223,6 +229,7 @@ public URL getURL() throws IOException {
/**
* This implementation returns a URI for the underlying file.
* @see java.io.File#toURI()
* @see java.nio.file.Path#toUri()
*/
@Override
public URI getURI() throws IOException {
Expand Down Expand Up @@ -324,6 +331,7 @@ public Resource createRelative(String relativePath) {
/**
* This implementation returns the name of the file.
* @see java.io.File#getName()
* @see java.nio.file.Path#getFileName()
*/
@Override
public String getFilename() {
Expand All @@ -334,6 +342,7 @@ public String getFilename() {
* This implementation returns a description that includes the absolute
* path of the file.
* @see java.io.File#getAbsolutePath()
* @see java.nio.file.Path#toAbsolutePath()
*/
@Override
public String getDescription() {
Expand All @@ -342,7 +351,7 @@ public String getDescription() {


/**
* This implementation compares the underlying File references.
* This implementation compares the underlying file paths.
*/
@Override
public boolean equals(@Nullable Object other) {
Expand All @@ -351,7 +360,7 @@ public boolean equals(@Nullable Object other) {
}

/**
* This implementation returns the hash code of the underlying File reference.
* This implementation returns the hash code of the underlying file path.
*/
@Override
public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,7 +61,7 @@ public class PathResource extends AbstractResource implements WritableResource {


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

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

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

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

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

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

/**
* This implementation returns a URI for the underlying file.
* This implementation returns a {@link URI} for the underlying file.
* @see java.nio.file.Path#toUri()
*/
@Override
Expand All @@ -192,7 +192,7 @@ public boolean isFile() {
}

/**
* This implementation returns the underlying File reference.
* This implementation returns the underlying {@link File} reference.
*/
@Override
public File getFile() throws IOException {
Expand All @@ -207,7 +207,7 @@ public File getFile() throws IOException {
}

/**
* This implementation opens a Channel for the underlying file.
* This implementation opens a {@link ReadableByteChannel} for the underlying file.
* @see Files#newByteChannel(Path, OpenOption...)
*/
@Override
Expand All @@ -221,7 +221,7 @@ public ReadableByteChannel readableChannel() throws IOException {
}

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

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

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


/**
* This implementation compares the underlying Path references.
* This implementation compares the underlying {@link Path} references.
*/
@Override
public boolean equals(@Nullable Object other) {
Expand All @@ -283,7 +283,7 @@ public boolean equals(@Nullable Object other) {
}

/**
* This implementation returns the hash code of the underlying Path reference.
* This implementation returns the hash code of the underlying {@link Path} reference.
*/
@Override
public int hashCode() {
Expand Down
Loading

0 comments on commit 5d4c284

Please sign in to comment.