Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

TaskStatus.timestamp is String, should be Date #892

Closed
johnflavin opened this issue Sep 19, 2017 · 1 comment
Closed

TaskStatus.timestamp is String, should be Date #892

johnflavin opened this issue Sep 19, 2017 · 1 comment

Comments

@johnflavin
Copy link
Contributor

Description

When you get a List<Task> from something like dockerClient.listTasks(), each Task has two date/time fields: Task.updatedAt() and Task.status().timestamp(). The latter is the exact same timestamp format as all the other timestamps in the docker API, but unlike all the others which are deserialized to Date this one is deserialized to String.

Compare the two timestamps in the JSON that gets returned from GET /tasks:

{
    "stuff": "...",
    "Status": {
        "Timestamp": "2017-09-19T16:21:36.051544316Z"
    },
    "UpdatedAt": "2017-09-19T16:21:36.264815225Z",
}

The formats are identical. They both should be deserialized to the same type.

Solution

We should have a TaskStatus method that returns the timestamp as a Date.

Seems simple. Why haven't I made a PR for this already?

I can see what needs to change, but I want to get opinions on how best to do it. I can think of two ways, but there may be more.

  1. Do I just change the signature of the existing method? This is super easy to do, but would break code for docker-client users.
  2. Do I make a new method and deprecate the old one? Because this is an AutoValue class, jackson will give it the String that is is asking for in its @JsonCreator method; jackson will not also give us a Date for the same property in the JSON. So it will require a bit of manual work to turn the existing String into a Date. This work would not be required in the first option, where jackson does the work turning the raw JSON from docker into a Date directly without ever passing it through a String property.
@mattnworb
Copy link
Member

I think 1 is fine if the current datatype is less than ideal. Should be easy enough for anyone using the String to change code.

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