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
Target Milestone: ---
: ---
Assignee: Nobody
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: jon3
TreeView+ depends on / blocked
 
Reported: 2011-07-27 18:04 UTC by Ian Springer
Modified: 2024-03-04 13:35 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Embargoed:


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.