Bug 972574

Summary: NPE in DataMigrator with empty (1h) table
Product: [Other] RHQ Project Reporter: Heiko W. Rupp <hrupp>
Component: MonitoringAssignee: Nobody <nobody>
Status: NEW --- QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.8CC: hrupp
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 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 Heiko W. Rupp 2013-06-10 07:04:37 UTC
Description of problem:

$ java -jar target/migrator-executable/data-migrator-4.8.0-SNAPSHOT.jar   --cassandra-port=9142
Estimation process - starting

java.lang.NullPointerException
	at org.rhq.server.metrics.migrator.workers.MetricsIndexUpdateAccumulator.getLastAggregationTime(MetricsIndexUpdateAccumulator.java:158)
	at org.rhq.server.metrics.migrator.workers.MetricsIndexUpdateAccumulator.<init>(MetricsIndexUpdateAccumulator.java:77)


This happens when e.g. the 1h (and probably the 6h) table has no data in it.

Problem is in


org.rhq.server.metrics.migrator.workers.MetricsIndexUpdateAccumulator#getLastAggregationTime
[...]
        if (duration != null && queryString != null) {
            Query query = session.createSQLQuery(queryString);
            String queryResult = query.uniqueResult().toString();

Here query.uniqueResult() can be null if no data is present