Skip to content

Commit

Permalink
Fixed 'comparison method violates general contract' during PDF import
Browse files Browse the repository at this point in the history
  • Loading branch information
buchen committed Dec 9, 2022
1 parent cc37be0 commit c83f8d8
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -9,6 +9,7 @@
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -155,10 +156,9 @@ public static void runImport(PortfolioPart part, Shell shell, Client client, Acc
public static void runImportWithFiles(PortfolioPart part, Shell shell, Client client, Account account,
Portfolio portfolio, List<File> files)
{
files.sort((File lhs, File rhs) -> {
int modDiff = (int) (lhs.lastModified() - rhs.lastModified());
return modDiff == 0 ? lhs.getPath().compareTo(rhs.getPath()) : modDiff;
});
// sort files to import purchase documents first (that typically create
// securities with better names)
files.sort(Comparator.comparing(File::lastModified).thenComparing(File::getPath));

IPreferenceStore preferences = part.getPreferenceStore();

Expand Down

0 comments on commit c83f8d8

Please sign in to comment.