Bug 886287

Summary: NullPointerException when another exception should have been thrown
Product: [Other] RHQ Project Reporter: Jesse Sightler <jsightle>
Component: AgentAssignee: Jirka Kremser <jkremser>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.5CC: hrupp, jkremser, jsightle
Target Milestone: ---   
Target Release: RHQ 4.6   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-03 10:46:10 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Jesse Sightler 2012-12-11 18:52:54 EST
Description of problem:

root/modules/common/ant-bundle/src/main/java/org/rhq/bundle/ant/type/SystemServiceType.java

The init method contains this:

if (this.configFile != null && !this.configFile.exists() || this.configFile.isDirectory()) {
            throw new BuildException("The 'configFile' attribute must be set to the path of an existing regular file.");
        }

Because of the lack of parenthesis, and the operator precendence rules of Java, this will not actually check that the config file is non-null.

Ie, if configFile is null, then this.configFile.isDirectory will still be called, resulting in a NullPointerException. I believe this should be changed to:

if (this.configFile != null && (!this.configFile.exists() || this.configFile.isDirectory())) {
            throw new BuildException("The 'configFile' attribute must be set to the path of an existing regular file.");
        }
Comment 1 Jirka Kremser 2012-12-14 08:51:53 EST
thanks, it is fixed now

http://git.fedorahosted.org/cgit/rhq/rhq.git/diff/?id=49a48ea47
time:    Fri Dec 14 14:50:57 2012 +0100
commit:  49a48ea47dde77506b48bb1c699dd6aab0ab8a20
author:  Jirka Kremser - jkremser@redhat.com
message: [BZ 886287 - NullPointerException when another exception should have been thrown] quick fix, lazy evaluation of Java should ensure the prevention of throwing NPE
Comment 2 Heiko W. Rupp 2013-09-03 10:46:10 EDT
Bulk closing of issues in old RHQ releases that are in production for a while now.

Please open a new issue when running into an issue.