From 5267e4d9854a56fbb61d1f25b67a537380e67494 Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Sun, 8 Sep 2024 12:25:44 +0300 Subject: [PATCH] Server: Add catch block to start-up data fetching This currently fails because the index site does not support IPv6. The server should tolerate this and continue execution instead of exiting. --- .../laane/server/service/importing/DataImportingJob.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/xyz/laane/server/service/importing/DataImportingJob.java b/server/src/main/java/xyz/laane/server/service/importing/DataImportingJob.java index c9a9998..12471d2 100644 --- a/server/src/main/java/xyz/laane/server/service/importing/DataImportingJob.java +++ b/server/src/main/java/xyz/laane/server/service/importing/DataImportingJob.java @@ -76,7 +76,11 @@ public void onApplicationEvent(final ApplicationReadyEvent event) { LocalDateTime lastFetch = batchRepository.findTopByOrderByTimestampDesc().getTimestamp(); if (lastFetch.isBefore(LocalDateTime.now().minusDays(DataImportingJob.FETCH_FREQUENCY_DAYS))) { log.info("Current stock data is older than {} days. Fetching new data.", DataImportingJob.FETCH_FREQUENCY_DAYS); - updateAllStocks(); + try { + updateAllStocks(); + } catch (Exception e) { + log.error("Failed to update stocks: {}", e.getMessage(), e); + } } else { log.debug("Current stock data is fresh. Not fetching new data"); }