Skip to content

Commit 4d92e1f

Browse files
committed
Added error handling for hashes with null value
1 parent f9cc126 commit 4d92e1f

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/main/java/eu/europa/ec/dgc/revocationdistribution/service/RevocationListDownloadServiceGatewayImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ private void postConstruct() {
7777
} catch (DateTimeParseException e) {
7878
log.error("Could not parse loaded last Updated timestamp: {}", lastUpdatedString);
7979
}
80+
} else {
81+
// Load initial timestamp
82+
try {
83+
lastUpdatedBatchDate = ZonedDateTime.parse("2021-06-01T00:00:00Z");
84+
} catch (DateTimeParseException e) {
85+
log.error("Could not parse loaded last Updated timestamp: 2021-06-01T00:00:00Z");
86+
}
8087
}
8188
}
8289

src/main/java/eu/europa/ec/dgc/revocationdistribution/service/RevocationListService.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,19 @@ public void updateRevocationListBatch(String batchId, RevocationBatchDto revocat
8080

8181
List<HashesEntity> hashes = new ArrayList<>();
8282

83-
for (RevocationBatchDto.BatchEntryDto hash : revocationBatchDto.getEntries()) {
84-
try {
85-
hashes.add(getHashEntity(batchListEntity, hash, revocationBatchDto.getKid()));
86-
} catch (IndexOutOfBoundsException e) {
87-
log.error("Error calculating x,y,z. Hash value length is to short: {}",
88-
hash.getHash().getBytes(StandardCharsets.UTF_8).length);
83+
84+
for (RevocationBatchDto.BatchEntryDto batchEntry : revocationBatchDto.getEntries()) {
85+
if (batchEntry.getHash() != null) {
86+
try {
87+
hashes.add(getHashEntity(batchListEntity, batchEntry, revocationBatchDto.getKid()));
88+
} catch (IndexOutOfBoundsException e) {
89+
log.error("Error calculating x,y,z. Hash value length is to short: {}",
90+
batchEntry.getHash().getBytes(StandardCharsets.UTF_8).length);
91+
} catch (IllegalArgumentException e) {
92+
log.error("Hash failed base64 decoding: {}", batchEntry.getHash());
93+
}
94+
} else {
95+
log.warn("Batch ({}) includes hash with null value, hash is ignored", batchId);
8996
}
9097
}
9198
hashesRepository.saveAll(hashes);

0 commit comments

Comments
 (0)