From 5333db97ea7543cff7fdb3cc93e7fab229472122 Mon Sep 17 00:00:00 2001 From: yhampe Date: Tue, 16 Jan 2024 09:55:48 +0100 Subject: [PATCH] RED-6805: As Operation I want to see why downloads are in an ERROR state reset errorcause when downloadstatus is ready ensuring lenghth of errorcause will not exceed field length --- .../service/download/DownloadDLQMessageReceiver.java | 2 ++ .../service/persistence/DownloadStatusPersistenceService.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/download/DownloadDLQMessageReceiver.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/download/DownloadDLQMessageReceiver.java index a8cc7f293..1dfa8e6ac 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/download/DownloadDLQMessageReceiver.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/download/DownloadDLQMessageReceiver.java @@ -27,6 +27,7 @@ public class DownloadDLQMessageReceiver { private final DownloadStatusPersistenceService downloadStatusPersistenceService; private final RetryTemplate retryTemplate; private final ObjectMapper objectMapper; + private final static int MAX_ERROR_CAUSE_LENGTH = 1024; @RabbitListener(queues = MessagingConfiguration.DOWNLOAD_COMPRESSION_DLQ) @@ -43,6 +44,7 @@ public class DownloadDLQMessageReceiver { var downloadJob = objectMapper.readValue(failedMessage.getBody(), DownloadJob.class); String errorCause = failedMessage.getMessageProperties().getHeader(X_ERROR_INFO_HEADER); + errorCause = errorCause.substring(0,MAX_ERROR_CAUSE_LENGTH-1); if (errorCause == null) { errorCause = "Error occured during download job!"; } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/DownloadStatusPersistenceService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/DownloadStatusPersistenceService.java index fb706f4b8..1d0c6ac1c 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/DownloadStatusPersistenceService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/DownloadStatusPersistenceService.java @@ -81,6 +81,10 @@ public class DownloadStatusPersistenceService { @Transactional public void updateStatus(DownloadStatusEntity entity, DownloadStatusValue statusValue, long fileSize) { + if(statusValue.equals(DownloadStatusValue.READY)) { + entity.setErrorCause(""); + } + entity.setStatus(statusValue); entity.setFileSize(fileSize); downloadStatusRepository.save(entity);