-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[nuki] Fixed configuration reload on initialization #12276
Conversation
responseEntity = doHandle(bridgeApiLockStateRequestDto, request.getParameter("bridgeId")); | ||
try { | ||
responseEntity = doHandle(bridgeApiLockStateRequestDto); | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably more something only for you as developer to find a potential bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, yes, that's exactly why I added it. If someone reports problem with callback I won't be able to debug it if I don't know what was sent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But do you have an example of exception by a user?
Why not rather analyzing the current code and only catch more specific exceptions?
In case this change makes sense, logging at warn level would be more appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I've said I've added it because I found some Nullpointers in logfile which I can't replicate (which means it could happen to someone else) and knowing what data were sent would really help. I agree that warn would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not fixing the NPE in this case, rather than catching the exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed the one place it throws NPE but it still would be helpful to see the data sent since that boolean flag should not be null
....nuki/src/main/java/org/openhab/binding/nuki/internal/handler/AbstractNukiDeviceHandler.java
Outdated
Show resolved
Hide resolved
1722650
to
6bd6c1a
Compare
....nuki/src/main/java/org/openhab/binding/nuki/internal/handler/AbstractNukiDeviceHandler.java
Outdated
Show resolved
Hide resolved
....nuki/src/main/java/org/openhab/binding/nuki/internal/handler/AbstractNukiDeviceHandler.java
Outdated
Show resolved
Hide resolved
....nuki/src/main/java/org/openhab/binding/nuki/internal/handler/AbstractNukiDeviceHandler.java
Outdated
Show resolved
Hide resolved
....nuki/src/main/java/org/openhab/binding/nuki/internal/handler/AbstractNukiDeviceHandler.java
Outdated
Show resolved
Hide resolved
....nuki/src/main/java/org/openhab/binding/nuki/internal/handler/AbstractNukiDeviceHandler.java
Outdated
Show resolved
Hide resolved
....nuki/src/main/java/org/openhab/binding/nuki/internal/handler/AbstractNukiDeviceHandler.java
Outdated
Show resolved
Hide resolved
How about this? I renamed the method, I didn't like the |
That looks even better now. |
Just to be clear, here is what I was suggesting:
Note that when the thing configuration is updated, I believe the core framework will dispose/initialize again the thing handler. So I believe the proper code should be:
but that would be better if you can test it (migration) because I am not 100% sure. |
* Fixed bug where thing configuration was not reloaded after reinitialization * Added better logging when processing bridge callback Signed-off-by: Jan Vybíral <jan.vybiral1@gmail.com>
I think the first one is correct, the handler needs to be initialized again every time config is updated, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Fixed bug where thing configuration was not reloaded after reinitialization * Added better logging when processing bridge callback Signed-off-by: Jan Vybíral <jan.vybiral1@gmail.com> Signed-off-by: Nick Waterton <n.waterton@outlook.com>
* Fixed bug where thing configuration was not reloaded after reinitialization * Added better logging when processing bridge callback Signed-off-by: Jan Vybíral <jan.vybiral1@gmail.com>
* Fixed bug where thing configuration was not reloaded after reinitialization * Added better logging when processing bridge callback Signed-off-by: Jan Vybíral <jan.vybiral1@gmail.com> Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
* Fixed bug where thing configuration was not reloaded after reinitialization * Added better logging when processing bridge callback Signed-off-by: Jan Vybíral <jan.vybiral1@gmail.com>
Fixed bug mentionend in https://community.openhab.org/t/new-openhab2-binding-for-nuki-smart-locks/25940/186.
When user changes configuration property (unlatch in this case), openhab calls
initialize()
on Thing, but since configuration was only loaded in constructor, any changes user made will not take effect until openhab restart or reinstallation of binding.I've also added logging of request received from bridge when handling callback, since I noticed some weird
NullpointerException
s in my logfile which were probably caused by invalid request, but without seeing the data sent it's hard to debug.