[optimization] Prevent unnecessary list creation

Prevent unnecessary list creation
This commit is contained in:
Erdinç Taşkın 2022-11-25 21:44:59 +03:00 committed by Jiri Pechanec
parent 68412ce15f
commit 97548591d6

View File

@ -163,7 +163,7 @@ private MongoDbOffsetContext getPreviousOffset(MongoDbConnectorConfig connectorC
Collection<Map<String, String>> partitions = loader.getPartitions();
Map<Map<String, String>, Map<String, Object>> offsets = context.offsetStorageReader().offsets(partitions);
if (offsets != null && !offsets.values().stream().filter(Objects::nonNull).collect(Collectors.toList()).isEmpty()) {
if (offsets != null && offsets.values().stream().anyMatch(Objects::nonNull)) {
MongoDbOffsetContext offsetContext = loader.loadOffsets(offsets);
logger.info("Found previous offsets {}", offsetContext);
return offsetContext;