Closed NorbertHD closed 7 years ago
Hey there, I am going to look into this. Thanks for reporting the observed situation. It was posted in the community forum, too (see here). Sometimes I received those NPEs suddenly in a running environment. It runs correctly for several days and then it fails. After a restart problem is gone. My experience with the used XML-parser is not very good, so I have no clue why this happens. I have implemented a fallback in Pull request #1815 which handles the NPEs. But currently there is no sulution for the problem itself.
Thank you for looking into this. I have also looked into the source and I think there are 2 issues.
In /avmfritz/internal/ahamodel/DeviceModel.java line 64 - 68:
58 @XmlElement(name = "present")
59 private Integer present;
60
61 @XmlElement(name = "name")
62 private String name;
63
64 private SwitchModel switchModel;
65
66 private PowerMeterModel powermeterModel;
67
68 private TemperatureModel temperatureModel;
I think this should be:
@XmlElement(name = "switch")
private SwitchModel switchModel;
@XmlElement(name = "powermeter")
private PowerMeterModel powermeterModel;
@XmlElement(name = "temperature")
private TemperatureModel temperatureModel;
Also in /avmfritz/internal/hardware/callbacks/FritzAhaUpdateXmlCallback.java on every "execute" a new JAXBContext is created. This is a memory leak. Only one static instance should be created.
See here: (http://stackoverflow.com/questions/3584821/jaxbcontext-newinstance-memory-leak) (https://jaxb.java.net/guide/Performance_and_thread_safety.html)
Thank you for those very helpful advices. I try adding those xml configuration in the DeviceModel.java tonight.
I put refactoring the use of JAXBContext as singleton on my TODO list.
// EDIT: I logged the used memory in my environment and confirm a memory leak.
Sometimes when I start openHAB on Windows 10 my 2 FRITZ!DECT 200 are correctly read. See log:
Some other time at start there are NullPointerExceptions because PowerMeterModel object is missing . This doesn't change until I restart openHAB. See log:
In both cases the syntax of the XML response is correct with slightly different values.
Good case:
Bad case:
But in the bad case the PowerMeterModel object ist null. ...mode=manuell,lock=0],<null>,org.openhab.binding...
I don't know how the XML parsing works. Is there an error in the XML parser initialization? Or why is the PowerMeterModel object not created with correct input?