Uh oh!
There was an error while loading. Please reload this page.
[java] Guard against NPE in Platform.extractFromSysProperty - #17151
Conversation
PR TypeBug fix Description
|
| Relevant files | |||
|---|---|---|---|
| Bug fix |
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label | |||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
| |||||||||
asolntsev
left a comment
There was a problem hiding this comment.
- few minor optional suggestions
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
* [java] Guard against NPE in Platform.extractFromSysProperty * [java] Improve null-safety and formatting in Platform.extractFromSysProperty * [java] Harden Platform.extractFromSysProperty against null inputs
💥 What does this PR do?
Prevents a possible
NullPointerExceptioninPlatform.extractFromSysProperty(String osName, String osVersion).Previously:
osNameandosVersionwere assumed to be non-nullosVersion.equals("6.2")could throwNullPointerExceptionnulldirectly from callersThis PR makes the method defensive against null inputs.
🔧 Implementation Notes
The following changes were made:
Normalize
osNameandosVersionusingObjects.requireNonNullElse:Provide a safe default when reading the system property:
These changes ensure:
💡 Additional Considerations
UNIXwhen no match is found🔄 Types of changes