Avoid calling JsonObject#size for compat with older gson versions (#2598)

This commit is contained in:
Luck 2020-09-05 22:00:56 +01:00
parent 5e48224c78
commit 2adaea2dac
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -101,12 +101,13 @@ public final class ContextSetJsonSerializer {
Preconditions.checkArgument(element.isJsonObject());
JsonObject jsonObject = element.getAsJsonObject();
if (jsonObject.size() == 0) {
Set<Map.Entry<String, JsonElement>> entries = jsonObject.entrySet();
if (entries.isEmpty()) {
return ImmutableContextSetImpl.EMPTY;
}
MutableContextSet contextSet = new MutableContextSetImpl();
for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
for (Map.Entry<String, JsonElement> entry : entries) {
String k = entry.getKey();
JsonElement v = entry.getValue();