Skip to content
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

[knx] Also catch IllegalArguementException in ValueDecoder to handle all error scenario, #18222

Open
lo92fr opened this issue Feb 3, 2025 · 0 comments
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@lo92fr
Copy link
Contributor

lo92fr commented Feb 3, 2025

Hello,

I hit the following error on my openhab / Knx installation.

2025-02-03 10:01:03.846 [DEBUG] [.internal.handler.DeviceThingHandler] - onGroupWrite Thing 'knx:device:bridge:generic' received a GroupValueWrite telegram from '1.0.248' for destination '10/4/3'
2025-02-03 10:01:03.846 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:
java.lang.IllegalArgumentException: Number cannot be parsed
at tech.units.indriya.format.NumberDelimiterQuantityFormat.parse(NumberDelimiterQuantityFormat.java:315) ~[?:?]
at org.openhab.core.library.types.QuantityType.(QuantityType.java:160) ~[?:?]
at org.openhab.core.library.types.QuantityType.(QuantityType.java:123) ~[?:?]
at org.openhab.binding.knx.internal.dpt.ValueDecoder.handleNumericDpt(ValueDecoder.java:505) ~[?:?]
at org.openhab.binding.knx.internal.dpt.ValueDecoder.decode(ValueDecoder.java:230) ~[?:?]
at org.openhab.binding.knx.internal.handler.DeviceThingHandler.processDataReceived(DeviceThingHandler.java:397) ~[?:?]
at org.openhab.binding.knx.internal.handler.DeviceThingHandler.onGroupWrite(DeviceThingHandler.java:385) ~[?:?]
at org.openhab.binding.knx.internal.client.AbstractKNXClient$1.lambda$0(AbstractKNXClient.java:129) ~[?:?]
at org.openhab.binding.knx.internal.client.AbstractKNXClient.lambda$8(AbstractKNXClient.java:348) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
at java.lang.Thread.run(Thread.java:1583) [?:?]

After investigating a little bit, I find that the error is triggered because one of the participant push a Not a Number (Nan) on this group 10/4/3.

Expected Behavior

What I expected in this case is to have a clae error in the exception telling me what group / participant / value make things goes wrong.
But I've only get the generic exception bellow.

After analysis the code, what is happenning is that:

  • The method public static @nullable Type decode(String dptId, byte[] data, Class<? extends Type> preferredType) of ValueDecoder is called to convert the raw value.

  • We hit in the case the handleNumericDpt(...) at the end of the swictch / case.

  • This method throw an IllegalArgumentException parsing the NaN.

  • But the catch clause in the decode function only catch NumberFormatException, not IllegalArgumentException.
    So the Logger.info just bellow is never it in this case.

So I think we have to changed:
``
} catch (NumberFormatException | KNXFormatException | KNXIllegalArgumentException | ParseException e) {

by

} catch (IllegalArgumentException | KNXFormatException | KNXIllegalArgumentException | ParseException e) {
``
that will cauth IllegalArgumentException as well as NumberFormatException

Your Environment

Openhab 5.x nightly, running on Fedora / Linux

@lo92fr lo92fr added the bug An unexpected problem or unintended behavior of an add-on label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

No branches or pull requests

1 participant