Skip to content

[Edge] EssCore: Fix NPE in "KeepingAllNearEqual" if mergedResult is null (or result.length is 0)#3277

Merged
sfeilmeier merged 1 commit intoOpenEMS:developfrom
opernikus-common:bugfix/NPE_InPowerObject
Aug 23, 2025
Merged

[Edge] EssCore: Fix NPE in "KeepingAllNearEqual" if mergedResult is null (or result.length is 0)#3277
sfeilmeier merged 1 commit intoOpenEMS:developfrom
opernikus-common:bugfix/NPE_InPowerObject

Conversation

@DerStoecki
Copy link
Copy Markdown
Contributor

We experienced NPE with the solver strategy of "KeepingAllNearEqual" when using multiple (2) ESS and put them into a cluster.
("Error during handleEvent(). NullPointerException: null")

When those two ESS were at 0 % no solution could be found and the mergedResult becomes null.

To prevent the NPE we check if the mergedResult is null and if the result.length is greater than 0 (the latter one might be not nec. but I still put this here in case it might occurr)

And return null if either is the case. Same as previously done (like when checking for NaN)

After implementing this change, we did not experience the NPE anymore

We experienced NPE with the solver strategy of "KeepingAllNearEqual" by using multiple ESS and put them into a cluster.
When those ESS were at 0 % no solution could be found and the mergedResult becomes null.

To prevent NPE we check for the null occurence and if the result.length is greater than 0 (the last one might be not nec. but I still put this here in case it might occurr)

And return null if either is the case. Same as previously done (like checking for NaN)

After implementing this change, we did not experience the NPE anymore
@DerStoecki DerStoecki requested a review from clehne August 14, 2025 10:34
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3277      +/-   ##
=============================================
- Coverage      59.42%   59.37%   -0.05%     
  Complexity       113      113              
=============================================
  Files           2763     2763              
  Lines         119343   119347       +4     
  Branches        8889     8891       +2     
=============================================
- Hits           70907    70845      -62     
- Misses         45766    45845      +79     
+ Partials        2670     2657      -13     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@sfeilmeier sfeilmeier left a comment

Choose a reason for hiding this comment

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

Thank you for providing a fix!

@sfeilmeier sfeilmeier merged commit 5cd19ea into OpenEMS:develop Aug 23, 2025
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants