tango-controls/JTango

NPE while calling DeviceDataHistory.getType()

jc17609 opened this issue · 1 comments

Running the attached test case, I get the following NPE while displaying the DeviceDataHistory items of a DevDouble Tango attribute.
I'm using JTango 9.1.2

java.lang.NullPointerException
at fr.esrf.TangoApi.DeviceDataHistoryDAODefaultImpl.getType(DeviceDataHistoryDAODefaultImpl.java:939)
at fr.esrf.TangoApi.DeviceDataHistory.getType(DeviceDataHistory.java:675)
at TangoJavaMonitorEsrf.getHistory(TangoJavaMonitorEsrf.java:82)

TangoJavaMonitorEsrf.java.zip

Hi Jerome

It is normal.
You have to take care to check if your attribute quality is VALID before getType() or extract()
If the attribute is NOT_VALID, there is no data inserted. So not type.
If you replace your code line 82 by:

if (historyItem.getAttrQuality()== AttrQuality.ATTR_VALID) System.out.println(historyItem.getType() + " - " + historyItem.getTime() + "-" + historyItem.getAttrQuality() + "-" + historyItem.extractDouble() + ", "); else System.err.println(" - " + historyItem.getTime() + "-" + historyItem.getAttrQuality());
It works fine.
Regards
Pascal