Skip to content

Commit

Permalink
Make it void, nothing is interested in return value.
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Apr 16, 2024
1 parent 2554475 commit ead1ace
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,16 @@ public class DefaultPathProcessor implements PathProcessor {
private final Logger logger = LoggerFactory.getLogger(getClass());

@Override
public boolean setLastModified(Path path, long value) throws IOException {
public void setLastModified(Path path, long value) throws IOException {
try {
Files.setLastModifiedTime(path, FileTime.fromMillis(value));
return true;
} catch (FileSystemException e) {
// MRESOLVER-536: Java uses generic FileSystemException for some weird cases,
// but some subclasses like AccessDeniedEx should be re-thrown
if (e instanceof AccessDeniedException) {
throw e;
}
logger.debug("Failed to set last-modified: {}", path, e);
return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ default long lastModified(Path path, long defValue) {
* Sets last modified of path in milliseconds, if exists.
*
* @param path The path, may be {@code null}.
* @throws IOException If an I/O error occurs.
* @return {@code true} if timestamp was successfully set, {@code false} otherwise. Reasons of {@code false} may
* be multiple, ranging from "file not found" to cases when FS does not support the setting the mtime.
* @throws IOException If an I/O error occurs. Some exceptions/reasons of failure to set mtime may be swallowed,
* and can be multiple, ranging from "file not found" to cases when FS does not support the setting the mtime.
* @since TBD
*/
boolean setLastModified(Path path, long value) throws IOException;
void setLastModified(Path path, long value) throws IOException;

/**
* Returns size of file, if exists.
Expand Down Expand Up @@ -122,13 +121,12 @@ default void copy(Path source, Path target) throws IOException {
* @param source The file to copy from, must not be {@code null}.
* @param target The file to copy to, must not be {@code null}.
* @throws IOException If an I/O error occurs.
* @return {@code true} if timestamp was successfully set, {@code false} otherwise.
* @see #setLastModified(Path, long)
* @since TBD
*/
default boolean copyWithTimestamp(Path source, Path target) throws IOException {
default void copyWithTimestamp(Path source, Path target) throws IOException {
copy(source, target, null);
return setLastModified(target, Files.getLastModifiedTime(source).toMillis());
setLastModified(target, Files.getLastModifiedTime(source).toMillis());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ public class TestPathProcessor implements PathProcessor {
private final TestFileProcessor testFileProcessor = new TestFileProcessor();

@Override
public boolean setLastModified(Path path, long value) throws IOException {
public void setLastModified(Path path, long value) throws IOException {
Files.setLastModifiedTime(path, FileTime.fromMillis(value));
return true;
}

public void mkdirs(Path directory) {
Expand Down

0 comments on commit ead1ace

Please sign in to comment.