From 1cd0ac49597c3188d210eb958f42097107c47579 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 6 Sep 2022 15:12:32 -0500 Subject: [PATCH] Changes from review --- .../java/org/eclipse/jetty/util/resource/Resource.java | 8 ++++---- .../java/org/eclipse/jetty/ee10/maven/plugin/Overlay.java | 2 +- .../java/org/eclipse/jetty/ee10/webapp/OrderingTest.java | 7 ------- .../java/org/eclipse/jetty/ee9/maven/plugin/Overlay.java | 2 +- .../java/org/eclipse/jetty/ee9/webapp/OrderingTest.java | 7 ------- 5 files changed, 6 insertions(+), 20 deletions(-) diff --git a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java index 139183f55bd..50531ce457f 100644 --- a/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java +++ b/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java @@ -181,16 +181,16 @@ public abstract class Resource * Equivalent to {@link Files#getLastModifiedTime(Path, LinkOption...)} with the following parameter: * {@link #getPath()} then returning {@link FileTime#toInstant()}. * - * @return the last modified time instant, or null if resource doesn't exist or doesn't have a last modified time. + * @return the last modified time instant, or {@link Instant#EPOCH} if unable to obtain last modified. */ public Instant lastModified() { Path path = getPath(); if (path == null) - return null; + return Instant.EPOCH; if (!Files.exists(path)) - return null; + return Instant.EPOCH; try { @@ -200,7 +200,7 @@ public abstract class Resource catch (IOException e) { LOG.trace("IGNORED", e); - return null; + return Instant.EPOCH; } } diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/Overlay.java b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/Overlay.java index 4b1a3a4eae0..61c58ef7447 100644 --- a/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/Overlay.java +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/main/java/org/eclipse/jetty/ee10/maven/plugin/Overlay.java @@ -86,7 +86,7 @@ public class Overlay throw new IllegalStateException("No overly unpack directory"); //only unpack if the overlay is newer Instant dirLastModified = Files.getLastModifiedTime(dir.toPath()).toInstant(); - if (!dir.exists() || (getResource().lastModified().isAfter(dirLastModified))) + if (!dir.exists() || getResource().lastModified().isAfter(dirLastModified)) getResource().copyTo(dir.toPath()); } } diff --git a/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/OrderingTest.java b/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/OrderingTest.java index 3ee1280251f..32a9e02a6d6 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/OrderingTest.java +++ b/jetty-ee10/jetty-ee10-webapp/src/test/java/org/eclipse/jetty/ee10/webapp/OrderingTest.java @@ -18,7 +18,6 @@ import java.io.InputStream; import java.net.URI; import java.nio.channels.ReadableByteChannel; import java.nio.file.Path; -import java.time.Instant; import java.util.ArrayList; import java.util.List; @@ -103,12 +102,6 @@ public class OrderingTest return false; } - @Override - public Instant lastModified() - { - return null; - } - @Override public long length() { diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/Overlay.java b/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/Overlay.java index 95077359cf9..c0ddb8250fc 100644 --- a/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/Overlay.java +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/main/java/org/eclipse/jetty/ee9/maven/plugin/Overlay.java @@ -86,7 +86,7 @@ public class Overlay throw new IllegalStateException("No overly unpack directory"); //only unpack if the overlay is newer Instant dirLastModified = Files.getLastModifiedTime(dir.toPath()).toInstant(); - if (!dir.exists() || (getResource().lastModified().isAfter(dirLastModified))) + if (!dir.exists() || getResource().lastModified().isAfter(dirLastModified)) getResource().copyTo(dir.toPath()); } } diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/OrderingTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/OrderingTest.java index bf1b5494a66..4dbd4778533 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/OrderingTest.java +++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/OrderingTest.java @@ -18,7 +18,6 @@ import java.io.InputStream; import java.net.URI; import java.nio.channels.ReadableByteChannel; import java.nio.file.Path; -import java.time.Instant; import java.util.ArrayList; import java.util.List; @@ -103,12 +102,6 @@ public class OrderingTest return false; } - @Override - public Instant lastModified() - { - return null; - } - @Override public long length() {