Summary
wikidata/json/NamespaceTypeAdapter.kt contains a backwards-compatibility branch that was explicitly marked for removal in 2017:
// Prior to 3210ce44, we marshaled Namespace as the name string of the enum, instead of
// the code number. This introduces a backwards-compatible check for the string value.
// TODO: remove after April 2017, when all older namespaces have been deserialized.
if (reader.peek() == JsonToken.STRING) {
return Namespace.valueOf(reader.nextString())
}
return Namespace.of(reader.nextInt())
The comment is now 9 years overdue. Any Namespace data serialized before commit 3210ce44 would have been deserialized and re-serialized many times since then, and will now be in the current integer format.
Proposed fix
Remove the STRING branch, leaving only:
return Namespace.of(reader.nextInt())
Before raising a PR
I'd like to confirm:
- Is there any known code path that could still produce a string-encoded
Namespace today (e.g. old cached data on device, API response, test fixture)?
- Is
Namespace.of(int) the only deserialization path we need after the removal?
Happy to raise a PR once these are confirmed. Thanks — Chris
Summary
wikidata/json/NamespaceTypeAdapter.ktcontains a backwards-compatibility branch that was explicitly marked for removal in 2017:The comment is now 9 years overdue. Any
Namespacedata serialized before commit3210ce44would have been deserialized and re-serialized many times since then, and will now be in the current integer format.Proposed fix
Remove the
STRINGbranch, leaving only:Before raising a PR
I'd like to confirm:
Namespacetoday (e.g. old cached data on device, API response, test fixture)?Namespace.of(int)the only deserialization path we need after the removal?Happy to raise a PR once these are confirmed. Thanks — Chris