Repository navigation
Improve null checking in MacInstalledApps - #3069
Conversation
📝 WalkthroughWalkthroughA null-safety fix in the MacInstalledApps parser that guards against null returns from parseStringArray when processing array values. Instead of allowing null propagation, the code now defaults to an empty string, preventing potential null dereference errors. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3069 +/- ##
==========================================
+ Coverage 84.56% 85.32% +0.75%
==========================================
Files 32 32
Lines 1458 1458
Branches 215 215
==========================================
+ Hits 1233 1244 +11
+ Misses 130 116 -14
- Partials 95 98 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@oshi-core/src/main/java/oshi/software/os/mac/MacInstalledApps.java`:
- Around line 183-185: The code sets val to "" when parseStringArray returns
null, which uses an empty-string sentinel that downstream logic may treat as a
real value; update the logic in MacInstalledApps (around extractBalancedInner
and parseStringArray) to avoid the empty-string sentinel: when parsed == null
either set val to Constants.UNKNOWN (importing/using the project Constants) or
omit inserting the map entry altogether so missing arrays are represented as
UNKNOWN/absent rather than "". Change the assignment of val (the variable
holding the parsed array result) and any subsequent map insertion to implement
the chosen behavior consistently.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
oshi-core/src/main/java/oshi/software/os/mac/MacInstalledApps.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test JDK 25, windows-latest
- GitHub Check: Test JDK 25, macos-latest
- GitHub Check: Analyze (java)
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Fixes #3068
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.