Bug 886287 - NullPointerException when another exception should have been thrown
NullPointerException when another exception should have been thrown
Status: CLOSED CURRENTRELEASE
Product: RHQ Project
Classification: Other
Component: Agent (Show other bugs)
4.5
Unspecified Unspecified
unspecified Severity unspecified (vote)
: ---
: RHQ 4.6
Assigned To: Jirka Kremser
Mike Foley
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-12-11 18:52 EST by Jesse Sightler
Modified: 2013-09-03 10:46 EDT (History)
3 users (show)

See Also:
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: ---


Attachments (Terms of Use)

  None (edit)
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.

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