From 4930f226151fbc548604dec1a19314f921d95945 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 20 Sep 2018 20:29:21 +0200 Subject: [PATCH] copy into new array when returning from resolver --- .../eu/siacs/conversations/utils/Resolver.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/utils/Resolver.java b/src/main/java/eu/siacs/conversations/utils/Resolver.java index 71ccde61d..6717b8a3f 100644 --- a/src/main/java/eu/siacs/conversations/utils/Resolver.java +++ b/src/main/java/eu/siacs/conversations/utils/Resolver.java @@ -106,14 +106,18 @@ public class Resolver { threads[1].join(); if (results.size() > 0) { threads[2].interrupt(); - Collections.sort(results); - Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + results.toString()); - return results; + synchronized (results) { + Collections.sort(results); + Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + results.toString()); + return new ArrayList<>(results); + } } else { threads[2].join(); - Collections.sort(fallbackResults); - Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + fallbackResults.toString()); - return fallbackResults; + synchronized (fallbackResults) { + Collections.sort(fallbackResults); + Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": " + fallbackResults.toString()); + return new ArrayList<>(fallbackResults); + } } } catch (InterruptedException e) { return results;