amihaiemil / docker-java-api

Lightweight Java Docker client
BSD 3-Clause "New" or "Revised" License
270 stars 53 forks source link

JsonException trying to access `LocalDocker.volumes()` #241

Closed sbespalov closed 5 years ago

sbespalov commented 5 years ago

Probably something wrong with expected JSON format.

How to reproduce:

    Volumes volumes = new LocalDocker(Paths.get("/var/run/docker.sock").toFile()).volumes();
    volumes.iterator();

Expected result: Got the volumes iterator

Actual result: javax.json.JsonException

Exception in thread "main" javax.json.JsonException: Cannot read JSON array, found JSON object
    at org.glassfish.json.JsonReaderImpl.readArray(JsonReaderImpl.java:122)
    at com.amihaiemil.docker.ReadJsonArray.handleResponse(ReadJsonArray.java:61)
    at com.amihaiemil.docker.ReadJsonArray.handleResponse(ReadJsonArray.java:1)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)
    at com.amihaiemil.docker.HttpClientEnvelope.execute(HttpClientEnvelope.java:103)
    at com.amihaiemil.docker.ResourcesIterator.<init>(ResourcesIterator.java:64)
    at com.amihaiemil.docker.ListedVolumes.iterator(ListedVolumes.java:78)
    at Main.main(Main.java:11)
0crat commented 5 years ago

@amihaiemil/z please, pay attention to this issue

amihaiemil commented 5 years ago

@sbespalov Right, turns out that List-Volumes operation returns a JsonObject, not a JsonArray:

https://docs.docker.com/engine/api/v1.30/#operation/VolumeList

The format is actually:

{
    "Volumes": [
        {}
     ],
    "Warnings": [ ]
}

Let's parse the response and iterate the Volumes array, ignore the Warnings for now.

0crat commented 5 years ago

Job #241 is now in scope, role is DEV

0crat commented 5 years ago

Bug was reported, see §29: +15 point(s) just awarded to @sbespalov/z

0crat commented 5 years ago

The job #241 assigned to @paulodamaso/z, here is why; the budget is 30 minutes, see §4; please, read §8 and §9; if the task is not clear, read this and this; there will be no monetary reward for this job

0crat commented 5 years ago

@paulodamaso/z this job was assigned to you 5days ago. It will be taken away from you soon, unless you close it, see §8. Read this and this, please.

paulodamaso commented 5 years ago

@sbespalov Merged, please close

0crat commented 5 years ago

The job #241 is now out of scope

0crat commented 5 years ago

Order was finished: +30 point(s) just awarded to @paulodamaso/z