Bug 1138805

Summary: remote agent install gets NPE during port check
Product: [JBoss] JBoss Operations Network Reporter: John Mazzitelli <mazz>
Component: Core ServerAssignee: John Mazzitelli <mazz>
Status: CLOSED CURRENTRELEASE QA Contact: Armine Hovsepyan <ahovsepy>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: JON 3.3.0CC: ahovsepy, mfoley
Target Milestone: ER03   
Target Release: JON 3.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-11 14:02:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description John Mazzitelli 2014-09-05 16:20:45 UTC
when installing a remote agent, if the check-for-used-port returns null, we through an NPE. We should not bomb out but keep going. Right now you just get an useless error message.

This code:

        // try to see if we can figure out what the port will be that the agent will bind to
        // this will use awk to find a line in the agent config xml that matches this:
        //    <entry key="rhq.communications.connector.bind-port" value="16163" />
        // where we use " as the field separator and the port number will be the fourth field.
        String agentPortAwkCommand = "awk '-F\"' '/key.*=.*" + AgentInstallInfo.AGENT_PORT_PROP + "/ {print $4}' "
            + "'" + agentConfigXmlFilename + "'";
        String portStr = executeCommand(agentPortAwkCommand, "Determine the agent's bind port", info);
        try {
            int port = Integer.parseInt(portStr.trim());
            info.setAgentPort(port);
        } catch (NumberFormatException nfe) {
            info.setAgentPort(0); // indicate that we don't know it
        }

Rather than just catch NumberFormatException, we should just catch Exception - that way, the NPE will get caught too - and we want to do the same thing - just indicate we don't know the port.

Comment 1 John Mazzitelli 2014-09-05 16:23:24 UTC
To master:

commit 0a87c043f2088934f3b66488c87f14e7b83b9e17
Author: John Mazzitelli <mazz>
Date:   Fri Sep 5 12:21:50 2014 -0400

    BZ 1138805 - NPE check

To release/jon3.3.x:

commit abe0958e98015fc7dfa12fc93a93d23f6c33bd03
Author: John Mazzitelli <mazz>
Date:   Fri Sep 5 12:21:50 2014 -0400

    BZ 1138805 - NPE check
    (cherry picked from commit 0a87c043f2088934f3b66488c87f14e7b83b9e17)

Comment 2 Simeon Pinder 2014-09-17 02:49:34 UTC
Moving to ON_QA as available for test with the following brew build:
https://brewweb.devel.redhat.com//buildinfo?buildID=385149

Comment 3 Armine Hovsepyan 2014-09-19 13:09:06 UTC
verified in JON 3.3 ER03
thank you