Description of problem: I ran into a NPE when trying to display a list of resources in the CLI when in interactive mode. Version-Release number of selected component (if applicable): How reproducible: Always with the specified criteria Steps to Reproduce: 1. Have a running server with resources in your auto-discovery queue 2. Execute the following commands from the CLI prompt $ login rhqadmin rhqadmin $ criteria = ResourceCriteria(); // no need to specifiy new operator $ criteria.addFilterInventoryStatus(InventoryStatus.NEW); $ resources = ResourceManager.findResourcesByCriteria(criteria); 3. An exception is throw before the results is printed to the console Actual results: java.lang.NullPointerException at org.rhq.enterprise.client.TabularWriter.shortVersion(TabularWriter.java:665) at org.rhq.enterprise.client.TabularWriter.print(TabularWriter.java:329) at org.rhq.enterprise.client.TabularWriter.print(TabularWriter.java:123) at org.rhq.enterprise.client.commands.ScriptCommand.execute(ScriptCommand.java:177) at org.rhq.enterprise.client.ClientMain.executePromptCommand(ClientMain.java:303) at org.rhq.enterprise.client.ClientMain$1.run(ClientMain.java:248) at java.lang.Thread.run(Thread.java:637) Expected results: Expected list of resources to be printed to the console. Additional info: This is not the first bug involving a NPE in TabularWriter that we have encountered. I am of the opinion that TabularWriter needs some significant refactoring; otherwise, I think we are going to see exceptions like this. It should also be noted that this exception does not happen for all resource queries. For instance, the following does not result in an exception: $ criteria = ResourceCriteria(); $ criteria.addFilterInventoryStatus(InventoryStatus.NEW); $ resources = ResourceManager.findResourcesByCriteria(criteria);
There is a copy/paste error in the description. The CLI commands for reproducing the NPE are, $ login rhqadmin rhqadmin $ criteria = ResourceCriteria(); // no need to specifiy new operator $ criteria.addFilterInventoryStatus(InventoryStatus.NEW); $ resources = ResourceManager.findResourcesByCriteria(criteria); But not all queries generate the exception. For instance, the following commands do not result in a NPE, $ login rhqadmin rhqadmin $ criteria = ResourceCriteria(); // no need to specifiy new operator $ resources = ResourceManager.findResourcesByCriteria(criteria);
If this is a regression of 2.3.1 it needs to be Urgent priority
I did not produce this exception with JON 2.3.1, so this must be a regression.
Added null checks to avoid NPEs as well as added several unit tests; however, I think there is still a good bit of refactoring needed in this code. I will open a separate bug for that. commit hash: e98a76091f74b19d89c6b5bac2ded52320a08df9
I tried this on jon-server-2.4.0.GA_QA build# 42, which was out just an hour back, and I'm still hitting NPE. rhqadmin.redhat.com:7080$ criteria = ResourceCriteria(); ResourceCriteria: inventoryManagerRequired: false persistentClass: class org.rhq.core.domain.resource.Resource rhqadmin.redhat.com:7080$ criteria.addFilterInventoryStatus(InventoryStatus.NEW); rhqadmin.redhat.com:7080$ resources = ResourceManager.findResourcesByCriteria(criteria); java.lang.NullPointerException at org.rhq.enterprise.client.TabularWriter.shortVersion(TabularWriter.java:674) at org.rhq.enterprise.client.TabularWriter.print(TabularWriter.java:337) at org.rhq.enterprise.client.TabularWriter.print(TabularWriter.java:123) at org.rhq.enterprise.client.commands.ScriptCommand.execute(ScriptCommand.java:177) at org.rhq.enterprise.client.ClientMain.executePromptCommand(ClientMain.java:303) at org.rhq.enterprise.client.ClientMain$1.run(ClientMain.java:248) at java.lang.Thread.run(Thread.java:636) I shall try it again on another latest build. So still keeping this with ON_QA.
Verified this against jon-server-2.4.0.GA_QA build# 44 rhqadmin.redhat.com:7080$ criteria = ResourceCriteria(); ResourceCriteria: inventoryManagerRequired: false persistentClass: class org.rhq.core.domain.resource.Resource rhqadmin.redhat.com:7080$ criteria.addFilterInventoryStatus(InventoryStatus.NEW); rhqadmin.redhat.com:7080$ resources = ResourceManager.findResourcesByCriteria(criteria); no data rhqadmin.redhat.com:7080$ I don't see NPE. Marking this bug as verified.
Mass-closure of verified bugs against JON.