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

[scale] NPE in ScaleTransformationService #8124

Merged
merged 1 commit into from
Jul 16, 2020
Merged

[scale] NPE in ScaleTransformationService #8124

merged 1 commit into from
Jul 16, 2020

Conversation

DerOetzi
Copy link
Contributor

@DerOetzi DerOetzi commented Jul 14, 2020

Fix #8011 and #8123

Signed-off-by: Johannes DerOetzi Ott [email protected]

Signed-off-by: Johannes DerOetzi Ott <[email protected]>
@DerOetzi DerOetzi requested a review from clinique as a code owner July 14, 2020 10:02
@TravisBuddy
Copy link

Travis tests were successful

Hey @DerOetzi,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@@ -129,7 +129,7 @@ private String formatResult(Map<Range, String> data, String source, final BigDec

private String getScaleResult(Map<Range, String> data, String source, final BigDecimal value)
throws TransformationException {
return data.entrySet().stream().filter(entry -> entry.getKey().contains(value)).findFirst()
return data.entrySet().stream().filter(entry -> entry.getKey() != null && entry.getKey().contains(value)).findFirst()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that the null value is the entry.getKey())? I'd thin it is actually the result of the filter(...) call and thus the findFirst() call causes the NPE.

@J-N-K
Copy link
Member

J-N-K commented Jul 14, 2020

The key is null:

.findFirst will return an empty Optional if no value is found.

@kaikreuzer
Copy link
Member

Oh, pretty unexpected, but thanks for pointing this out! Then the fix should be alright, I guess.

@kaikreuzer
Copy link
Member

But I leave the final decision & merge to you, @J-N-K as you already helped on the investigation.

@J-N-K
Copy link
Member

J-N-K commented Jul 14, 2020

I can't judge whether adding NaN to the scale-file makes sense or not. My original implementation was rejected because the scale-file I introduced for the was not considered useful. So this should be merged by someone who uses humidex-scale.

@DerOetzi
Copy link
Contributor Author

I can't judge whether adding NaN to the scale-file makes sense or not. My original implementation was rejected because the scale-file I introduced for the was not considered useful. So this should be merged by someone who uses humidex-scale.

@cpmeister and @clinique you had comments on this at #8013 can you please have a look!

@J-N-K J-N-K merged commit 2fca998 into openhab:2.5.x Jul 16, 2020
@J-N-K J-N-K added this to the 2.5.7 milestone Jul 16, 2020
@J-N-K J-N-K added the bug An unexpected problem or unintended behavior of an add-on label Jul 16, 2020
CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this pull request Jul 26, 2020
Signed-off-by: Johannes DerOetzi Ott <[email protected]>t>
Signed-off-by: CSchlipp <[email protected]>
MPH80 pushed a commit to MPH80/openhab-addons that referenced this pull request Aug 3, 2020
Signed-off-by: Johannes DerOetzi Ott <[email protected]>t>
Signed-off-by: MPH80 <[email protected]>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this pull request Sep 1, 2020
Signed-off-by: Johannes DerOetzi Ott <[email protected]>t>
Signed-off-by: Daan Meijer <[email protected]>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Sep 19, 2020
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

Successfully merging this pull request may close these issues.

NPE in ScaleTransformationService
5 participants