Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1689175

Summary: NullPointerException in case of wrong parameters in api calls via java sdk
Product: [oVirt] ovirt-engine-sdk-java Reporter: suman.swaroop
Component: CoreAssignee: Ondra Machacek <omachace>
Status: CLOSED CURRENTRELEASE QA Contact: Lucie Leistnerova <lleistne>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.2.1CC: bugs, juan.hernandez, lleistne, mperina, rbarry
Target Milestone: ovirt-4.3.4Keywords: Reopened
Target Release: 4.3.1Flags: mperina: ovirt-4.3?
lleistne: testing_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: java-ovirt-engine-sdk-4.3.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-11 06:24:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1710395    

Description suman.swaroop 2019-03-15 11:01:05 UTC
Description of problem:
Whenever we send a request to fetch any component detail like VM, datacenter
and if the id doesnot exist then the response throws a 404. In ovirt-engine-sdk HTTPConnection.java class send method, there is a check to verify whether the reponse header has content-type xml or not. for 404 response I am sure that this is not set and hence the getHeader function returns null which throws Null pointer exception. I suspect that all non-ok responses will lead to null pointer exception instead of some other proper error message.

Version-Release number of selected component (if applicable):


How reproducible:
Everytime

Steps to Reproduce:

Using ovirt engine java sdk,
conn.systemService().vmsService().vmService("<vm-id>").get().send();
This throws NUllpointerException

Actual results:
Failed to Send request, throws NullPointerException
 
Expected results:
I expect that proper Exceptions to be thrown in case of wrong Ids, or any other parameter being wrong in api calls. Or atleast a response object is returned with proper error codes and messages if possible


Additional info:

Comment 1 Ravi Nori 2019-03-18 13:33:20 UTC
If conn.systemService().vmsService().vmService("<vm-id>") return null because the vm does not exist for the id. A get on the vm would throw an NPE.

I suggest storing conn.systemService().vmsService().vmService("<vm-id>") in a variable and check if it is null before invoking a get on it.

Closing as not a bug

Comment 2 suman.swaroop 2019-03-18 13:36:56 UTC
That's what I am doing right now but would have expected a better response with proper error codes and messages.This makes debugging difficult.

Comment 3 suman.swaroop 2019-03-18 13:43:51 UTC
Last comment is somewhat not complete. conn.systemservice....vmService returns the vmservice, there is no api call involved yet and it is never null. The moment a api call is made using get method of the service, the response does not have content-type field then the send function in HttpConnection class throws NPE if vm id does not exist. proper checks should have been there in the send request.

Comment 4 Lucie Leistnerova 2019-06-06 20:25:43 UTC
running system services with non existing ID throws exception:
Error: HTTP response code is "404". HTTP response message is "Not Found"

Verified in java-ovirt-engine-sdk4-4.3.1-1.el7ev.noarch

Comment 5 Sandro Bonazzola 2019-06-11 06:24:03 UTC
This bugzilla is included in oVirt 4.3.4 release, published on June 11th 2019.

Since the problem described in this bug report should be
resolved in oVirt 4.3.4 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.