Parsing integer config entries results in an error since 3.3.0-STABLE

Hello fellow developers!

I’ve got an issue with my bundle Synology Surveillance Station Binding and the latest 3.3.0-STABLE

There is a config parameter, defined as integer:

with its corresponding group:
image

Normally I’m parsing this value using:

int streamId = Integer.parseInt(thing.getConfiguration().get("snapshot-stream-id").toString());

If I’m looking into
\userdata\jsondb\org.openhab.core.thing.Thing.json
I see my parameter properly set:

image

This value stays persisted upon OH restart.

Until 3.3.0RC it worked as intended, now I’m observing a different behavior.

The creation of this Thing seems to work as intended, json file looks proper…
but after OH restart all entries are changed into decimal values:

image

As expected, it causes an exception upon parsing:

java.lang.NumberFormatException: For input string: “1.0”

Now I could use Float.parseFloat instead or try/catch this error but it’s a dirty solution and I’m still wondering how could it be possible and whether it’s a bug or a feature :wink:

Thanks in advance!
Pav

1 Like

@J-N-K : could I in relation yo that PR?

This is the omly recent one related to config parameters.

1 Like

No, this is just the same root cause which I fixed for the validation. I proposed Normalize thing configuration before initialization by J-N-K · Pull Request #3024 · openhab/openhab-core · GitHub. But parsing configuration in that way should be avoided in any case. I believe if you define a configuration class and use .as on the configuration, you will not run into trouble.

2 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.