diff --git a/src/main/java/com/hoelee/jsonplaceholder/post/PostService.java b/src/main/java/com/hoelee/jsonplaceholder/post/PostService.java index 6598446..3ff5df0 100644 --- a/src/main/java/com/hoelee/jsonplaceholder/post/PostService.java +++ b/src/main/java/com/hoelee/jsonplaceholder/post/PostService.java @@ -88,11 +88,13 @@ public class PostService { List candidates = received.stream() .filter(this::isImportable) .toList(); - Set knownSourceIds = postRepository.findAllBySourcePostIdIn( - candidates.stream().map(JsonPlaceholderPost::id).toList()) - .stream() - .map(Post::getSourcePostId) + Set candidateSourceIds = candidates.stream().map(JsonPlaceholderPost::id) .collect(java.util.stream.Collectors.toSet()); + Set knownSourceIds = candidateSourceIds.isEmpty() + ? Set.of() + : postRepository.findAllBySourcePostIdIn(candidateSourceIds).stream() + .map(Post::getSourcePostId) + .collect(java.util.stream.Collectors.toSet()); Set seenSourceIds = new HashSet<>(); List newPosts = candidates.stream() .filter(remotePost -> !knownSourceIds.contains(remotePost.id())) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6bcd053..df2b347 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -9,9 +9,6 @@ spring: open-in-view: false hibernate: ddl-auto: update - cache: - caffeine: - spec: maximumSize=500,expireAfterWrite=10m mvc: problemdetails: enabled: true