Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HostAndPortDeserializer rely on older version property name #45

Closed
Nireus opened this issue Mar 11, 2019 · 1 comment
Closed

HostAndPortDeserializer rely on older version property name #45

Nireus opened this issue Mar 11, 2019 · 1 comment
Milestone

Comments

@Nireus
Copy link

Nireus commented Mar 11, 2019

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;
  }
@cowtowncoder
Copy link
Member

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.

@cowtowncoder cowtowncoder added 2.9 and removed 2.10 labels Apr 6, 2019
@cowtowncoder cowtowncoder modified the milestones: 2, 2.9.9 Apr 6, 2019
cowtowncoder added a commit that referenced this issue Apr 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants