Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Serialization Discrepancy in SessionInfo #40

Closed
bearrito opened this issue Jul 26, 2015 · 2 comments
Closed

Serialization Discrepancy in SessionInfo #40

bearrito opened this issue Jul 26, 2015 · 2 comments

Comments

@bearrito
Copy link

Serialization
The SessionInfo seems unable to parse SessionInfo with non-null TTL

The below json fails to post using sessionClient.createSession

{"Name":"service-1","TTL":"600"}

The below json works using sessionClient.createSession (addition of s to TTL)

{"Name":"service-1","TTL":"600s"}

This seems supported by the docs : https://www.consul.io/docs/agent/http/session.html#session_create

Deserialization
However SessionInfo TTL is a Long and and there doesn't seem to be a serde that intercepts.

In particular the below is thrown

Problem with reading the data, class [Lcom.orbitz.consul.model.session.SessionInfo;, ContentType: application/json.
javax.ws.rs.client.ResponseProcessingException: Problem with reading the data, class [Lcom.orbitz.consul.model.session.SessionInfo;, ContentType: application/json.
    at org.apache.cxf.jaxrs.impl.ResponseImpl.reportMessageHandlerProblem(ResponseImpl.java:433)
    at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:378)
    at org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:512)
....

Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of long from String value '600s': not a valid Long value
 at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@11ce4975; line: 1, column: 182] (through reference chain: Object[][0]->com.orbitz.consul.model.session.SessionInfo["TTL"])

I'm more familiar with Spray and haven't done much with Jackson, but I can put together a PR for this if someone can confirm the issue and that it isn't an issue of my usage.

@rickfast
Copy link
Owner

Looks like a real issue. Feel free to send a PR, or I can fix next week when I'm back at work.

@rickfast
Copy link
Owner

Fixed by 5a12ecc

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants