From 004504b04cb6aebbf6d2f39346687f4a2376e2d1 Mon Sep 17 00:00:00 2001 From: Arne Date: Thu, 3 Oct 2024 16:45:06 +0200 Subject: [PATCH] Code cleanup --- proguard-rules.pro | 1 + .../java/eu/siacs/conversations/entities/Reaction.java | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/proguard-rules.pro b/proguard-rules.pro index 6402760831..61d8981b79 100644 --- a/proguard-rules.pro +++ b/proguard-rules.pro @@ -7,6 +7,7 @@ -keep class com.kyleduo.switchbutton.Configuration +# Needed for proper GSON deserialization -keep class com.google.gson.reflect.TypeToken -keep class * extends com.google.gson.reflect.TypeToken -keep public class * implements java.lang.reflect.Type diff --git a/src/main/java/eu/siacs/conversations/entities/Reaction.java b/src/main/java/eu/siacs/conversations/entities/Reaction.java index 38eb46d4c4..54cd938335 100644 --- a/src/main/java/eu/siacs/conversations/entities/Reaction.java +++ b/src/main/java/eu/siacs/conversations/entities/Reaction.java @@ -21,8 +21,6 @@ import com.google.gson.stream.JsonWriter; import eu.siacs.conversations.xmpp.Jid; import java.io.IOException; -import java.lang.reflect.Type; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -76,9 +74,8 @@ public class Reaction { return Collections.emptyList(); } try { - Type type = new TypeToken>() {}.getType(); - return GSON.fromJson(asString, type); - } catch (final JsonSyntaxException e) { + return GSON.fromJson(asString, new TypeToken>() {}.getType()); + } catch (final IllegalArgumentException | JsonSyntaxException e) { return Collections.emptyList(); } }