History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: RHQ-508
Type: Code Change Code Change
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Joseph Marques
Reporter: Heiko W. Rupp
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
RHQ Project

RecursiveGroupTest swallows NPEs

Created: 21/May/08 05:46 AM   Updated: 22/Jul/08 12:57 PM
Component/s: None
Affects Version/s: 0.1
Fix Version/s: 1.1

Time Tracking:
Not Specified

Resolution Date: 19/Jul/08 09:35 PM
Date of First Response: 19/Jul/08 09:35 PM
VCS Revision: 1,122


 Description  « Hide
Run the test with a debugger stopping on NPEs

e.g.
org.rhq.enterprise.server.resource.group.test.RecursiveResourceGroupTest.testImplicitGroupMembershipFromInventoryUpdate():
            Resource nodeOne = ResourceTreeHelper.findNode(fullTree, "1");
            resourceGroupManager
                .addResourcesToGroup(subject, recursiveGroup.getId(), new Integer[] { nodeOne.getId() });

If nodeOne is null, nodeOne.getId() yields a NPE which got silently swallowed later, so the Test never fails.


ResourceTreeHelper:

   public static List<Resource> getSubtree(Resource resource) {
        List<Resource> subtree = new ArrayList<Resource>();

        List<Resource> toBeSearched = new LinkedList<Resource>();
        toBeSearched.add(resource);
        while (toBeSearched.size() > 0) {
            Resource next = toBeSearched.get(0);
            subtree.add(next);
            toBeSearched.addAll(next.getChildResources());
        }

next is null in the testsuite called from org.rhq.enterprise.server.resource.group.test.RecursiveResourceGroupTest.testImplicitGroupMembershipFromComplexGroupUpdates()

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Joseph Marques - 19/Jul/08 09:35 PM
rev1122 - RecursiveGroupTest allows exceptions to bubble up to the test framework, instead of swallowing them;

Heiko, findBugs? ; )

Joseph Marques - 19/Jul/08 09:35 PM
jeff, no testing necessary here - this is a code-level fix.