Skip to content

Conversation

@rohan-coder02
Copy link
Collaborator

@rohan-coder02 rohan-coder02 commented Nov 14, 2025

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.

SystemInfo si = new SystemInfo();

System.out.println(si.getOperatingSystem().getInstalledApplications());

System.out.println(si.getHardware().getGraphicsCards());

To fix #3023

Copy link

Copilot AI left a 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 RegistryUtil class 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 InstalledAppsData and WindowsGraphicsCard to 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.

…; remove additional space added in hex fallback
@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 60.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.32%. Comparing base (b3ac570) to head (a12e3ca).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
oshi-core/src/main/java/oshi/util/ParseUtil.java 60.00% 1 Missing and 3 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


private static final Logger LOG = LoggerFactory.getLogger(ParseUtil.class);

private static final Charset CP1252 = Charset.forName("Windows-1252");
Copy link
Member

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 :)

@dbwiddis dbwiddis merged commit 6a92699 into oshi:master Nov 22, 2025
14 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.

Unexpected registry type on Windows 7

2 participants