raepple / nanoleaf-binding

openHAB binding for the Nanoleaf Light Panels
4 stars 0 forks source link

Exception when adding light panel in PaperUI #4

Closed olemr closed 1 year ago

olemr commented 5 years ago

Java exception when trying to add 1 of 102 light panels. Any hard coded array sizes perhaps?

openhab> list | grep -i nano
202 │ Active │  80 │ 2.5.0.201907121940    │ openHAB Add-ons :: Bundles :: Nanoleaf Binding
2019-09-29 16:15:15.672 [WARN ] [al.handler.NanoleafControllerHandler] - Update job failed
java.lang.ArrayIndexOutOfBoundsException: 713
        at org.openhab.binding.nanoleaf.internal.handler.NanoleafPanelHandler.getPanelColor(NanoleafPanelHandler.java:263) ~[?:?]
        at org.openhab.binding.nanoleaf.internal.handler.NanoleafPanelHandler.updatePanelColorChannel(NanoleafPanelHandler.java:216) ~[?:?]
        at org.openhab.binding.nanoleaf.internal.handler.NanoleafControllerHandler.lambda$3(NanoleafControllerHandler.java:469) ~[?:?]
        at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:?]
        at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080) ~[?:?]
        at org.openhab.binding.nanoleaf.internal.handler.NanoleafControllerHandler.updateFromControllerInfo(NanoleafControllerHandler.java:465) ~[?:?]
        at org.openhab.binding.nanoleaf.internal.handler.NanoleafControllerHandler.runUpdate(NanoleafControllerHandler.java:318) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]
stefan-hoehn commented 4 years ago

@olemr

It is actually weird: When I look about the code that must have been out by the time you wrote this ticket, the NanoPanelHandler.java did not have a line 263. However, even though the line number does not match I found the following code

` getPanelColor():

String panelID = getThing().getConfiguration().get(NanoleafBindingConstants.CONFIG_PANEL_ID).toString(); if (panelInfo.get(panelID) == null) {`

where panelInfo is a map that was loaded some time before. If for some reason that panel has been added but the controller has not updated from the device it would just not find that in the map.

The current code is different from that it always queries from the controller the values before getting the color.

I would therefore presume that we won't have that problem anymore.

stefan-hoehn commented 1 year ago

Asked @olemr and it works without any issues today.