From bb2355d0357f9d4ecaca4ef95126491c8f49e2b3 Mon Sep 17 00:00:00 2001 From: esaunders Date: Wed, 15 Jan 2020 12:41:00 -0500 Subject: [PATCH] Cannot call pages.clear() because Lists.partition() returns an unmodifiable list. Reset pages by creating a new empty ArrayList. --- .../sleuthkit/autopsy/datamodel/BaseChildFactory.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/BaseChildFactory.java b/Core/src/org/sleuthkit/autopsy/datamodel/BaseChildFactory.java index d3a27a1eb3..123ec7d7c3 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/BaseChildFactory.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/BaseChildFactory.java @@ -286,8 +286,14 @@ public abstract class BaseChildFactory extends ChildFactory.D * If pageSize is set split keys into pages, otherwise create a * single page containing all keys. */ - if (keys.isEmpty()) { - pages.clear(); + if (keys.isEmpty() && !pages.isEmpty()) { + /** + * If we previously had keys (i.e. pages is not empty) and now + * we don't have keys, reset pages to an empty list. + * Cannot use a call to List.clear() here because the call to + * Lists.partition() below returns an unmodifiable list. + */ + pages = new ArrayList<>(); } else { pages = Lists.partition(keys, pageSize > 0 ? pageSize : keys.size()); }