What steps can reproduce the defect?
Please share the setup, sample project, version of Java etc.
Occasionally, when querying for azure utilization by subscription by customer, the PartnerServiceClient.handleResponse method throws a ClassCastException. This occurs when a 204 response is handled with an empty body. Here's an example query:
Here's where PartnerServiceClient.handleResponse triggers the exception:
response = httpClient().newCall(request).execute();
if(response.isSuccessful())
{
responseBody = response.body().string();
if(StringHelper.isNullOrEmpty(responseBody))
{
value = (T)response; // <--- THIS CAUSES ClassCastException
}
else
{
value = getJsonConverter().readValue(responseBody, responseType);
}
response.close();
return value;
}
Expected behavior
Share the expected output
I'd expect a null to be returned, or some form of not found exception to be thrown, but never a class cast exception, especially for a 204 response, which is defined as not having a response body.
Actual behavior
What is the behavior observed?
ClassCastException is thrown.
Diagnostic logs
Please share test platform diagnostics logs.
The logs may contain test assembly paths, kindly review and mask those before sharing.
Environment
Please share additional details about your environment.
Version
Observed this behavior with both versions 1.13.2 and 1.15.3, and I see that the latest code on master (1.15.4) will do the same.
Steps to reproduce
Occasionally, when querying for azure utilization by subscription by customer, the PartnerServiceClient.handleResponse method throws a ClassCastException. This occurs when a 204 response is handled with an empty body. Here's an example query:
Here's where PartnerServiceClient.handleResponse triggers the exception:
Expected behavior
I'd expect a null to be returned, or some form of not found exception to be thrown, but never a class cast exception, especially for a 204 response, which is defined as not having a response body.
Actual behavior
ClassCastException is thrown.
Diagnostic logs
Environment
Observed this behavior with both versions 1.13.2 and 1.15.3, and I see that the latest code on master (1.15.4) will do the same.