From fafa23c72cb7b32271c3ecb0c02472a70726cb6a Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 16 Aug 2024 00:06:38 -0300 Subject: [PATCH 1/2] fix: log the error instead of throwing an exception --- .../java/com/rollbar/notifier/sender/queue/DiskQueue.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rollbar-java/src/main/java/com/rollbar/notifier/sender/queue/DiskQueue.java b/rollbar-java/src/main/java/com/rollbar/notifier/sender/queue/DiskQueue.java index 01700471..4924bd75 100644 --- a/rollbar-java/src/main/java/com/rollbar/notifier/sender/queue/DiskQueue.java +++ b/rollbar-java/src/main/java/com/rollbar/notifier/sender/queue/DiskQueue.java @@ -43,12 +43,12 @@ private DiskQueue(Builder builder) { if (!this.queueFolder.exists()) { if (!this.queueFolder.mkdirs()) { - throw new RuntimeException("Could not create folder: " + queueFolder); + LOGGER.error("Could not create folder: {}", queueFolder); } } if (!this.queueFolder.canRead() || !this.queueFolder.canWrite()) { - throw new RuntimeException("Not enough permissions folder: " + queueFolder); + LOGGER.error("Not enough permissions folder: {}", queueFolder); } } From 269d4f64bd3a17f7c7760b991049962e23bd6b83 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 4 Sep 2024 11:30:15 -0300 Subject: [PATCH 2/2] docs: add comment --- .../java/com/rollbar/notifier/sender/queue/DiskQueue.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rollbar-java/src/main/java/com/rollbar/notifier/sender/queue/DiskQueue.java b/rollbar-java/src/main/java/com/rollbar/notifier/sender/queue/DiskQueue.java index 4924bd75..74108d5e 100644 --- a/rollbar-java/src/main/java/com/rollbar/notifier/sender/queue/DiskQueue.java +++ b/rollbar-java/src/main/java/com/rollbar/notifier/sender/queue/DiskQueue.java @@ -41,6 +41,10 @@ private DiskQueue(Builder builder) { this.maxSize = builder.maxSize; this.queueFolder = builder.queueFolder; + /* + A RuntimeException can cause a silent crash, since the error would not be saved and in the next + session there would be no payload to send. So we just log the error. + */ if (!this.queueFolder.exists()) { if (!this.queueFolder.mkdirs()) { LOGGER.error("Could not create folder: {}", queueFolder);