You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HostAndPortDeserializer should use field name host instead of hostText
jackson-datatypes-collections:guava
@Override
public HostAndPort deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException
{
// Need to override this method, which otherwise would work just fine,
// since we have legacy JSON Object format to support too:
if (p.currentToken() == JsonToken.START_OBJECT) { // old style
JsonNode root = p.readValueAsTree();
String host = root.path("hostText").asText();
JsonNode n = root.get("port");
if (n == null) {
return HostAndPort.fromString(host);
}
return HostAndPort.fromParts(host, n.asInt());
}
return super.deserialize(p, ctxt);
}
Guava
/**
* Returns the portion of this {@code HostAndPort} instance that should represent the hostname or
* IPv4/IPv6 literal.
*
* <p>A successful parse does not imply any degree of sanity in this field. For additional
* validation, see the {@link HostSpecifier} class.
*
* @since 20.0 (since 10.0 as {@code getHostText})
*/
public String getHost() {
return host;
}
The text was updated successfully, but these errors were encountered:
First question: which library is this about? Guava? If so, could you please add Label to indicate that?
Second: Assuming this is Guava, we may have a problem: Jackson does not require Guava 20; for 2.9 and 2.10 minimum version is 18. Ideally it would work with multiple versions.
But as long as we can accept either host or hostText that should be fine: code should be able to check newer field (I think) first, and only if not found, older.
HostAndPortDeserializer
should use field namehost
instead ofhostText
jackson-datatypes-collections:guava
Guava
The text was updated successfully, but these errors were encountered: