From 3145350d7bf68f0875ec4d691a93af01bf6688dd Mon Sep 17 00:00:00 2001 From: Volodymyr_Rohach Date: Wed, 17 Jan 2024 14:22:21 +0200 Subject: [PATCH] MODSOURMAN-1063: Bug fixed. --- .../src/main/java/org/folio/dao/JournalRecordDaoImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mod-source-record-manager-server/src/main/java/org/folio/dao/JournalRecordDaoImpl.java b/mod-source-record-manager-server/src/main/java/org/folio/dao/JournalRecordDaoImpl.java index 2021ce913..2f552681f 100644 --- a/mod-source-record-manager-server/src/main/java/org/folio/dao/JournalRecordDaoImpl.java +++ b/mod-source-record-manager-server/src/main/java/org/folio/dao/JournalRecordDaoImpl.java @@ -572,8 +572,12 @@ private static RecordProcessingLogDtoCollection processMultipleHoldingsAndItemsI List relatedHoldingsInfos = relatedHoldingsInfoBySourceRecordId.get(sourceRecordId); List relatedItemInfos = relatedItemInfoBySourceId.get(sourceRecordId); - RecordProcessingLogDto firstRecordWithCurrentSourceId = entries.stream().filter(record -> - record.getSourceRecordId().equals(sourceRecordId)).findFirst().get(); + Optional optionalRecord = entries.stream() + .filter(record -> record.getSourceRecordId().equals(sourceRecordId)).findFirst(); + RecordProcessingLogDto firstRecordWithCurrentSourceId = new RecordProcessingLogDto(); + if (optionalRecord.isPresent()) { + firstRecordWithCurrentSourceId = optionalRecord.get(); + } RecordProcessingLogDto newRecord = firstRecordWithCurrentSourceId .withRelatedHoldingsInfo(relatedHoldingsInfos.stream().distinct().toList()) .withRelatedItemInfo(relatedItemInfos.stream().distinct().toList());