From 18679cfe90410e612164bb94b0e3fb661b62f7f5 Mon Sep 17 00:00:00 2001 From: Bartosz Litwiniuk <> Date: Wed, 1 Nov 2023 22:00:14 +0100 Subject: [PATCH 1/4] Fix db record null --- .../library/services/BacktraceDatabaseContext.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backtrace-library/src/main/java/backtraceio/library/services/BacktraceDatabaseContext.java b/backtrace-library/src/main/java/backtraceio/library/services/BacktraceDatabaseContext.java index b4a23861..eeb3f5a1 100644 --- a/backtrace-library/src/main/java/backtraceio/library/services/BacktraceDatabaseContext.java +++ b/backtrace-library/src/main/java/backtraceio/library/services/BacktraceDatabaseContext.java @@ -348,11 +348,17 @@ private BacktraceDatabaseRecord getLastRecord() { private BacktraceDatabaseRecord getRecordFromCache(boolean reverse) { for (int i = _retryNumber - 1; i >= 0; i--) { List reverseRecords = batchRetry.get(i); + + if (reverseRecords == null) { + continue; + } + if (reverse) { Collections.reverse(reverseRecords); } + for (BacktraceDatabaseRecord record : reverseRecords) { - if (!record.locked) { + if (record != null && !record.locked) { record.locked = true; return record; } From f2d2c04d62904684c0c51250d17ca4fdff5c370f Mon Sep 17 00:00:00 2001 From: Bartosz Litwiniuk <> Date: Thu, 2 Nov 2023 23:29:21 +0100 Subject: [PATCH 2/4] Small refactor --- .../library/services/BacktraceDatabaseContext.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backtrace-library/src/main/java/backtraceio/library/services/BacktraceDatabaseContext.java b/backtrace-library/src/main/java/backtraceio/library/services/BacktraceDatabaseContext.java index eeb3f5a1..e8274e69 100644 --- a/backtrace-library/src/main/java/backtraceio/library/services/BacktraceDatabaseContext.java +++ b/backtrace-library/src/main/java/backtraceio/library/services/BacktraceDatabaseContext.java @@ -72,7 +72,7 @@ public BacktraceDatabaseContext(Context context, BacktraceDatabaseSettings setti */ private BacktraceDatabaseContext(Context context, String path, int retryNumber, RetryOrder retryOrder) { this._applicationContext = context; - this._path = path;//this.getAbsolutePath(path); + this._path = path; this._retryNumber = retryNumber; this.retryOrder = retryOrder; setupBatch(); @@ -297,9 +297,9 @@ public boolean removeOldestRecord() { */ private void incrementBatches() { for (int i = this._retryNumber - 2; i >= 0; i--) { - List temp = this.batchRetry.get(i); + List currentBatch = this.batchRetry.get(i); batchRetry.put(i, new ArrayList()); - batchRetry.put(i + 1, temp); + batchRetry.put(i + 1, currentBatch); } } From 2de2d765da8063f91b227420fb56d2611714f9d0 Mon Sep 17 00:00:00 2001 From: Bartosz Litwiniuk <> Date: Thu, 2 Nov 2023 23:29:58 +0100 Subject: [PATCH 3/4] Test to check adding null records --- .../library/database/BacktraceDatabaseContextTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backtrace-library/src/androidTest/java/backtraceio/library/database/BacktraceDatabaseContextTest.java b/backtrace-library/src/androidTest/java/backtraceio/library/database/BacktraceDatabaseContextTest.java index 7ff08a58..a05ce0b3 100644 --- a/backtrace-library/src/androidTest/java/backtraceio/library/database/BacktraceDatabaseContextTest.java +++ b/backtrace-library/src/androidTest/java/backtraceio/library/database/BacktraceDatabaseContextTest.java @@ -229,6 +229,16 @@ public void tryDeleteNotExistingRecordFromDatabaseContext() { assertEquals(3, databaseContext.count()); } + @Test(expected = NullPointerException.class) + public void tryAddNullBacktraceData() { + databaseContext.add((BacktraceData) null); + } + + @Test(expected = NullPointerException.class) + public void tryAddNullBacktraceDbRecord() { + databaseContext.add((BacktraceDatabaseRecord) null); + } + private List fillDatabase() { List result = new ArrayList<>(); BacktraceReport report = new BacktraceReport(this.testMessage); From 94a3d5dfcdaa964ba2b5f60ade773e6f2a17883a Mon Sep 17 00:00:00 2001 From: Bartosz Litwiniuk <> Date: Sat, 4 Nov 2023 19:33:15 +0100 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aacc5a7..ea088a41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Backtrace Android Release Notes +## Version 3.7.11 +- Fix NPE in DatabaseContext +- Add session attribute and backtrace reporter name to every error report + ## Version 3.7.10 - Add integration tests - Move common http response processing method to helper class