Bug 726172 - potential NPE in LogFileEventResourceComponentHelper.startLogFileEventPollers() if 'enabled' log event source prop is undefined or null
Summary: potential NPE in LogFileEventResourceComponentHelper.startLogFileEventPollers...
Keywords:
Status: NEW
Alias: None
Product: RHQ Project
Classification: Other
Component: Plugin Container
Version: 4.0.1
Hardware: Unspecified
OS: Unspecified
low
low vote
Target Milestone: ---
: ---
Assignee: RHQ Project Maintainer
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: jon3
TreeView+ depends on / blocked
 
Reported: 2011-07-27 18:04 UTC by Ian Springer
Modified: 2015-02-01 23:29 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:


Attachments (Terms of Use)

Description Ian Springer 2011-07-27 18:04:52 UTC
Here's the offending lines:

Boolean enabled = Boolean.valueOf(logEventSource.getSimpleValue(LogEventSourcePropertyNames.ENABLED, null));
            if (enabled) {

The NPE could occur at the if-check if a plugin set the 'enabled' prop to null or did not initialize it at all. 

The code should be changed to:

Boolean enabled = Boolean.valueOf(logEventSource.getSimpleValue(LogEventSourcePropertyNames.ENABLED, null));
            if (enabled == null) {
               String logFilePath =  logEventSource.getSimpleValue(LogEventSourcePropertyNames.LOG_FILE_PATH, null);
               log.warn("Plugin error: 'enabled' property is null for event source for log file [" + logFilePath + "] - this property is required and should always be set. Assuming the event source is disabled...");
                enabled = Boolean.FALSE;
            }
            if (enabled) {


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