tango-controls / JTango

TANGO kernel Java implementation. JTango moved to https://gitlab.com/tango-controls/JTango
http://tango-controls.org
8 stars 14 forks source link

NPE while calling DeviceDataHistory.getType() #59

Closed jc17609 closed 6 years ago

jc17609 commented 6 years ago

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

Pascal-Verdier commented 6 years ago

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