-
-
Notifications
You must be signed in to change notification settings - Fork 915
Add RegistryUtil class in oshi-core to handle unexpected registry types #3024
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
Add RegistryUtil class in oshi-core to handle unexpected registry types #3024
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new RegistryUtil utility class to centralize and improve Windows Registry value reading by handling unexpected registry types (REG_BINARY, REG_SZ, REG_EXPAND_SZ, REG_DWORD). The refactoring addresses issue #3023 where registry values stored as binary data were causing failures, and maintains the fix from PR #2973 for timestamp handling.
Key changes:
- New
RegistryUtilclass with methods to read registry values as String or Long, with automatic type handling and conversion - Binary data decoding support with multiple encoding fallbacks (UTF-16LE, UTF-8, Windows-1252, hex)
- Refactored
InstalledAppsDataandWindowsGraphicsCardto use the new utility instead of duplicated code
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java | New utility class providing centralized registry reading with type conversion and binary decoding support |
| oshi-core/src/main/java/oshi/driver/windows/registry/InstalledAppsData.java | Refactored to use RegistryUtil, removing ~110 lines of duplicated registry handling code |
| oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsGraphicsCard.java | Updated to use RegistryUtil for reading registry string values |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
…; remove additional space added in hex fallback
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
oshi-core/src/main/java/oshi/util/platform/windows/RegistryUtil.java
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3024 +/- ##
==========================================
+ Coverage 84.87% 85.32% +0.44%
==========================================
Files 32 32
Lines 1448 1458 +10
Branches 213 215 +2
==========================================
+ Hits 1229 1244 +15
+ Misses 123 116 -7
- Partials 96 98 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(ParseUtil.class); | ||
|
|
||
| private static final Charset CP1252 = Charset.forName("Windows-1252"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the shortened name here :)
Description:
Testing:
Compared the outputs using oshi 6.9.1 and with the current code changes (oshi-core-6.9.2-SNAPSHOT) in ideal scenario, the outputs match.
To fix #3023