Bug 886287 - NullPointerException when another exception should have been thrown
Summary: NullPointerException when another exception should have been thrown
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Agent
Version: 4.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: RHQ 4.6
Assignee: Jirka Kremser
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-12-11 23:52 UTC by Jesse Sightler
Modified: 2013-09-03 14:46 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-09-03 14:46:10 UTC
Embargoed:


Attachments (Terms of Use)

Description Jesse Sightler 2012-12-11 23:52:54 UTC
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 13:51:53 UTC
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
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 14:46:10 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.