matthiasblaesing commented on PR #7533:
URL: https://github.com/apache/netbeans/pull/7533#issuecomment-2207060122

   @lukaz-sampaio the alternative from my perspective would be to keep the 
attribute and fill it on a best-effort basis. If `VirtualSize` is not present, 
report the value of `Size` for it. I looked at the output of `docker image ls 
--format json` and to me the two values are just differently rounded. Something 
like this:
   
   ```java
       @SuppressWarnings("unchecked")
       public List<DockerImage> getImages() {
           try {
               JSONArray value = (JSONArray) doGetRequest("/images/json",
                       Collections.singleton(HttpURLConnection.HTTP_OK));
               List<DockerImage> ret = new ArrayList<>(value.size());
               for (Object o : value) {
                   JSONObject json = (JSONObject) o;
                   JSONArray repoTags = (JSONArray) json.get("RepoTags");
                   String id = (String) json.get("Id");
                   long created = (long) json.getOrDefault("Created", 0L);
                   long size = (long) json.getOrDefault("Size", 0L);
                   long virtualSize = (long) json.getOrDefault("VirtualSize", 
size);
                   ret.add(new DockerImage(instance, repoTags, id, created, 
size, virtualSize));
               }
               return ret;
           } catch (DockerException ex) {
               LOGGER.log(Level.INFO, null, ex);
           }
           return Collections.emptyList();
       }
   ```
   
   Callers now get the closest thing to the right size, without breaking 
compatibility. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to