Bug 1135136 - NPE in MySQL plugin when PID_FILE value not found in database
Summary: NPE in MySQL plugin when PID_FILE value not found in database
Keywords:
Status: ON_QA
Alias: None
Product: RHQ Project
Classification: Other
Component: Plugins
Version: 4.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: RHQ 4.13
Assignee: Elias Ross
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-28 22:16 UTC by Elias Ross
Modified: 2022-03-31 04:27 UTC (History)
2 users (show)

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


Attachments (Terms of Use)

Description Elias Ross 2014-08-28 22:16:26 UTC
Description of problem:

This code can NPE:

diff --git a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
index 3cd2401..bc0ed90 100644
--- a/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
+++ b/modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java
@@ -225,6 +225,9 @@ private AggregateProcessInfo findProcessInfo() {
     private long findPID() {
         long result = -1;
         String pidFile = globalVariables.get("PID_FILE");
+        if (pidFile == null) {
+            return result;
+        }
         File file = new File(pidFile);
         if (file.canRead()) {
             try {

This can happen perhaps to permission issues or not finding that data. The change is to simply test for null here.

The fix is +

The logs:

 2014-08-28 18:55:36,106 DEBUG [MeasurementManager.collector-1] (rhq.core.pc.inventory.ResourceContainer$ResourceComponentInvocationHandler)- Call to [org.rhq.plugins.mysql.MySqlComponent.getValues()] with args [[org.rhq.core.domain.measurement.MeasurementReport@61cd2828, [ScheduledMeasurementInfo[res=1136602, name=Questions, sched=12384747], ScheduledMeasurementInfo[res=1136602, name=Process.aggregateMemory.pageFaults, sched=12384615], ScheduledMeasurementInfo[res=1136602, name=Connections, sched=12384696], ScheduledMeasurementInfo[res=1136602, name=Process.aggregateCpu.total, sched=12384459], ScheduledMeasurementInfo[res=1136602, name=Open_tables, sched=12384738], ScheduledMeasurementInfo[res=1136602, name=Process.aggregateFileDescriptor.total, sched=12384736], ScheduledMeasurementInfo[res=1136602, name=Process.aggregateCpu.percent, sched=12384846], ScheduledMeasurementInfo[res=1136602, name=Process.aggregateCpu.user, sched=12384449], ScheduledMeasurementInfo[res=1136602, name=Max_used_connections, sched=12384724], ScheduledMeasurementInfo[res=1136602, name=Process.aggregateMemory.size, sched=12384673], ScheduledMeasurementInfo[res=1136602, name=Process.aggregateCpu.sys, sched=12384490], ScheduledMeasurementInfo[res=1136602, name=Process.aggregateMemory.resident, sched=12384427]]]] failed.
java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:232)
        at java.util.concurrent.FutureTask.get(FutureTask.java:91)
        at org.rhq.core.pc.inventory.ResourceContainer$ResourceComponentInvocationHandler.invokeInNewThreadWithLock(ResourceContainer.java:574)
        at org.rhq.core.pc.inventory.ResourceContainer$ResourceComponentInvocationHandler.invoke(ResourceContainer.java:562)
        at $Proxy82.getValues(Unknown Source)
        at org.rhq.core.pc.measurement.MeasurementCollectorRunner.getValues(MeasurementCollectorRunner.java:131)
        at org.rhq.core.pc.measurement.MeasurementCollectorRunner.call(MeasurementCollectorRunner.java:111)
        at org.rhq.core.pc.measurement.MeasurementManager$MeasurementCollectionRequester.run(MeasurementManager.java:178)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
        at java.io.File.<init>(File.java:222)
        at org.rhq.plugins.mysql.MySqlComponent.findPID(MySqlComponent.java:172)
        at org.rhq.plugins.mysql.MySqlComponent.findProcessInfo(MySqlComponent.java:155)
        at org.rhq.plugins.mysql.MySqlComponent.getValues(MySqlComponent.java:105)
        at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.rhq.core.pc.inventory.ResourceContainer$ComponentInvocation.call(ResourceContainer.java:669)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        ... 3 more



Version-Release number of selected component (if applicable): 4.9, but also 4.12+


How reproducible: Depending on MySQL permissions


Steps to Reproduce:

Unclear exact steps.

Comment 1 Thomas Segismont 2014-10-16 13:25:31 UTC
  Branch: refs/heads/master
  Home:   https://github.com/rhq-project/rhq
  Commit: c3d779e37aeb27f040777b88f7a254782188b471
      https://github.com/rhq-project/rhq/commit/c3d779e37aeb27f040777b88f7a254782188b471
  Author: Elias Ross <elias_ross>
  Date:   2014-10-15 (Wed, 15 Oct 2014)

  Changed paths:
    M modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java

  Log Message:
  -----------
  Bug 1135136 - NPE in MySQL plugin when PID_FILE value not found in database


  Commit: 326fbcd02e0885f96a442704c11ad2c8f00c4ae4
      https://github.com/rhq-project/rhq/commit/326fbcd02e0885f96a442704c11ad2c8f00c4ae4
  Author: Thomas Segismont <tsegismont>
  Date:   2014-10-16 (Thu, 16 Oct 2014)

  Changed paths:
    M modules/plugins/mysql/src/main/java/org/rhq/plugins/mysql/MySqlComponent.java

  Log Message:
  -----------
  Merge pull request #140 from genman/bug/1135136

Bug 1135136 - NPE in MySQL plugin when PID_FILE value not found in database


Compare: https://github.com/rhq-project/rhq/compare/98fb73759744...326fbcd02e08


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