aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThatGamerBlue <thatgamerblue@gmail.com>2020-05-25 17:32:40 +0100
committerGitHub <noreply@github.com>2020-05-25 19:32:40 +0300
commite98c0a4f98c72c90b429e803bc1967e0056ba541 (patch)
tree5615c0a9ecd02daf8c534ca273c8efae2832a427
parent032d8c7a79fc2bb613a9e07228fd21d8a0280430 (diff)
downloadpf4j-e98c0a4f98c72c90b429e803bc1967e0056ba541.tar.gz
pf4j-e98c0a4f98c72c90b429e803bc1967e0056ba541.zip
sort files using last modified as long, preventing downcasting errors (#376)
-rw-r--r--pf4j/src/main/java/org/pf4j/BasePluginRepository.java2
-rw-r--r--pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java3
2 files changed, 3 insertions, 2 deletions
diff --git a/pf4j/src/main/java/org/pf4j/BasePluginRepository.java b/pf4j/src/main/java/org/pf4j/BasePluginRepository.java
index 8c856f8..ea5ad3b 100644
--- a/pf4j/src/main/java/org/pf4j/BasePluginRepository.java
+++ b/pf4j/src/main/java/org/pf4j/BasePluginRepository.java
@@ -48,7 +48,7 @@ public class BasePluginRepository implements PluginRepository {
this.filter = filter;
// last modified file is first
- this.comparator = (o1, o2) -> (int) (o2.lastModified() - o1.lastModified());
+ this.comparator = Comparator.comparingLong(File::lastModified);
}
public void setFilter(FileFilter filter) {
diff --git a/pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java b/pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java
index bcf1535..e841189 100644
--- a/pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java
+++ b/pf4j/src/test/java/org/pf4j/AbstractExtensionFinderTest.java
@@ -18,6 +18,7 @@ package org.pf4j;
import com.google.common.collect.ImmutableList;
import com.google.common.io.ByteStreams;
import com.google.testing.compile.Compilation;
+import java.util.Comparator;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -238,7 +239,7 @@ public class AbstractExtensionFinderTest {
public Map<String, Class<?>> loadClasses(List<JavaFileObject> classes) throws IOException {
// Sort generated ".class" by lastModified field
- classes.sort((c1, c2) -> (int) (c1.getLastModified() - c2.getLastModified()));
+ classes.sort(Comparator.comparingLong(JavaFileObject::getLastModified));
// Load classes
Map<String, Class<?>> loadedClasses = new HashMap<>(classes.size());