mirror of
https://github.com/fankes/moshi.git
synced 2025-10-18 23:49:21 +08:00
Unconditionally close the peeked JsonReader. (#810)
It doesn't have an effect now, but this is for the future when closing the peeked source also clears buffers.
This commit is contained in:
@@ -235,7 +235,12 @@ public final class PolymorphicJsonAdapterFactory<T> implements JsonAdapter.Facto
|
||||
@Override public Object fromJson(JsonReader reader) throws IOException {
|
||||
JsonReader peeked = reader.peekJson();
|
||||
peeked.setFailOnUnknown(false);
|
||||
int labelIndex = labelIndex(peeked);
|
||||
int labelIndex;
|
||||
try {
|
||||
labelIndex = labelIndex(peeked);
|
||||
} finally {
|
||||
peeked.close();
|
||||
}
|
||||
if (labelIndex == -1) {
|
||||
reader.skipValue();
|
||||
return defaultValue;
|
||||
@@ -262,7 +267,6 @@ public final class PolymorphicJsonAdapterFactory<T> implements JsonAdapter.Facto
|
||||
+ reader.nextString()
|
||||
+ "'. Register a subtype for this label.");
|
||||
}
|
||||
reader.close();
|
||||
return labelIndex;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user