Skip to content

Fix JSCalendar without recurrence rule#3197

Merged
sfeilmeier merged 5 commits intoOpenEMS:developfrom
opernikus-common:feature/JSCalendarFix
Jun 23, 2025
Merged

Fix JSCalendar without recurrence rule#3197
sfeilmeier merged 5 commits intoOpenEMS:developfrom
opernikus-common:feature/JSCalendarFix

Conversation

@tsicking
Copy link
Copy Markdown
Contributor

Previously, a NullPointerException was thrown when parsing a JSCalendar-Entry without a recurrence rule. This is fixed here, and JUnit tests are added.

@tsicking tsicking requested a review from clehne June 19, 2025 08:00
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #3197      +/-   ##
=============================================
+ Coverage      58.87%   59.09%   +0.22%     
- Complexity       173      181       +8     
=============================================
  Files           2619     2662      +43     
  Lines         113027   114360    +1333     
  Branches        8318     8407      +89     
=============================================
+ Hits           66536    67565    +1029     
- Misses         44000    44266     +266     
- Partials        2491     2529      +38     
🚀 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.

@clehne clehne requested a review from sfeilmeier June 20, 2025 08:09
@sfeilmeier
Copy link
Copy Markdown
Contributor

@michaelgrill Can you please validate? Shouldn't the mapIfPresent variant also work?

@tsicking
Copy link
Copy Markdown
Contributor Author

@michaelgrill Can you please validate? Shouldn't the mapIfPresent variant also work?

It doesn't work because mapIfPresent returns null, and therefore forEach throws a NullPointerException. Here is the result of the JUnit test with the old code:

image

@michaelgrill
Copy link
Copy Markdown
Contributor

michaelgrill commented Jun 23, 2025

@sfeilmeier
@tsicking is right mapIfPresent returns null if not included in the json (as mentioned in the javadoc). Use mapToOptional or the shortest way would be something like this
json.getOptionalList("recurrenceRules", RecurrenceRule.serializer()).orElse(Collections.emptyList())

@tsicking
Copy link
Copy Markdown
Contributor Author

@sfeilmeier @tsicking is right mapIfPresent returns null if not included in the json (as mentioned in the javadoc). Use mapToOptional or the shortest way would be something like this json.getOptionalList("recurrenceRules", RecurrenceRule.serializer()).orElse(Collections.emptyList())

Thanks for your quick response. Your suggestion also works and is slightly more elegant, so I changed it accordingly.

@sfeilmeier
Copy link
Copy Markdown
Contributor

Thank you all! 👍🚀

@sfeilmeier sfeilmeier merged commit f2b7c0b into OpenEMS:develop Jun 23, 2025
2 checks passed
@clehne clehne deleted the feature/JSCalendarFix branch June 23, 2025 10:27
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.

4 participants