Bug 968134

Summary: AlertAvailabilityDurationJob can throw NPE
Product: [Other] RHQ Project Reporter: Elias Ross <genman>
Component: AlertsAssignee: Jay Shaughnessy <jshaughn>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.5CC: hrupp
Target Milestone: ---   
Target Release: RHQ 4.8   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-10 14:46:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Elias Ross 2013-05-29 03:58:34 UTC
Description of problem:

2013-05-29 00:16:17,143 ERROR [org.rhq.enterprise.server.scheduler.jobs.AbstractStatefulJob] Failed to execute job [AlertAvailabilityDurationJob]
java.lang.NullPointerException
        at org.rhq.enterprise.server.scheduler.jobs.AlertAvailabilityDurationJob.executeJobCode(AlertAvailabilityDurationJob.java:58)
        at org.rhq.enterprise.server.scheduler.jobs.AbstractStatefulJob.execute(AbstractStatefulJob.java:48)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)


Version-Release number of selected component (if applicable): 4.5.1


Unclear how to reproduce this, but I'm guessing:

+        // get the current resource availability
+        ResourceAvailability resourceAvail = LookupUtil.getResourceAvailabilityManager().getLatestAvailability(
+            resourceId);
+        AvailabilityType availType = resourceAvail.getAvailabilityType();

resourceAvail is null... The fix might be:

@@ -55,7 +55,7 @@ public void executeJobCode(JobExecutionContext context) throws JobExecutionExcep
         // get the current resource availability
         ResourceAvailability resourceAvail = LookupUtil.getResourceAvailabilityManager().getLatestAvailability(
             resourceId);
-        AvailabilityType availType = resourceAvail.getAvailabilityType();
+        AvailabilityType availType = resourceAvail != null ? resourceAvail.getAvailabilityType() : AvailabilityType.DOWN;
 
         // Question? Do we care whether the avail type has been the same for the entire duration (meaning we would need
         // to go and find the most recent Availability record)?  Or do we only care if it is currently at the avail

Comment 1 Heiko W. Rupp 2013-06-17 09:41:41 UTC
I think this got fixed recently by jshaughn in 58d7b1bb4678daa13fe9a2f527ba28031c9d8d68

Assigning to him nevertheless for verification.

Comment 2 Jay Shaughnessy 2013-09-10 14:46:31 UTC
This was fixed previously

commit 58d7b1bb4678daa13fe9a2f527ba28031c9d8d68
Author: Jay Shaughnessy <jshaughn>
Date:   Wed Jun 5 10:04:22 2013 -0400

    Fix issue with alert duration job when the resource in question is
    removed from inventory during the duration period.