cloudfoundry / cf-java-client

Java Client Library for Cloud Foundry
Apache License 2.0
328 stars 318 forks source link

Get stats for app process lead to IllegalStateException #1133

Closed theghost5800 closed 2 years ago

theghost5800 commented 2 years ago

I find out that if execute http request to start application and after that get stats for application. CF API can return the following response[1] and due to check here it throws the following error[2]. This could be occur for short time during startup of application, after some time if http request is retried, then required fields are properly set but during startup it looks like this fields can be null. Is this check necessary at all? The issue was reproduced using cf-java-client 4.16.0 and CF environment is at API version 3.111.0

[1]

{
  "resources":[
    {
      "type":"web",
      "index":0,
      "state":"STARTING",
      "host":"",
      "uptime":4,
      "mem_quota":null,
      "disk_quota":null,
      "fds_quota":32768,
      "isolation_segment":null,
      "details":null,
      "instance_ports":[],
      "usage":{
        "time":"2022-02-03T12:34:14+00:00",
        "cpu":0,
        "mem":0,
        "disk":0
      }
    }
  ]
}

[2]

org.cloudfoundry.reactor.util.JsonParsingException: Cannot construct instance of `org.cloudfoundry.client.v3.processes.ProcessStatisticsResource`, problem: Cannot build ProcessStatisticsResource, some of required attributes are not set [diskQuota, memoryQuota]
pivotal-david-osullivan commented 2 years ago

Thanks for the report. It looks like this is a bug, according to the Process Stats object, the mem_quota and disk_quota fields can be null when the data is unavailable so these should likely be removed from the check.

dmikusa commented 2 years ago

+1 seems like we're being overly strict in our validations. Thanks for the report.

@theghost5800 - Did you want to submit a PR for this? I know you've submitted in the past. If not, that's OK too, and we can queue this up to be fixed.