From 2adaea2dac6c390028e28f69e2cbdbf7ce49878f Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 5 Sep 2020 22:00:56 +0100 Subject: [PATCH] Avoid calling JsonObject#size for compat with older gson versions (#2598) --- .../luckperms/common/context/ContextSetJsonSerializer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java index c00500bf6..bcee83d31 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java @@ -101,12 +101,13 @@ public final class ContextSetJsonSerializer { Preconditions.checkArgument(element.isJsonObject()); JsonObject jsonObject = element.getAsJsonObject(); - if (jsonObject.size() == 0) { + Set> entries = jsonObject.entrySet(); + if (entries.isEmpty()) { return ImmutableContextSetImpl.EMPTY; } MutableContextSet contextSet = new MutableContextSetImpl(); - for (Map.Entry entry : jsonObject.entrySet()) { + for (Map.Entry entry : entries) { String k = entry.getKey(); JsonElement v = entry.getValue();