Skip to content
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

Fix Deprecated Warnings for Compatibility with Java 21 #2922

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

Sn0w3y
Copy link
Contributor

@Sn0w3y Sn0w3y commented Dec 12, 2024

Description:

This pull request addresses deprecated warnings that arose due to the migration to Java 21. The changes primarily involve replacing deprecated methods with modern alternatives to ensure the codebase adheres to updated Java best practices and remains maintainable in future versions. The updates specifically focus on replacing Runtime.getRuntime().exec() with ProcessBuilder, as exec(String) has been deprecated since Java 18.

Key Changes:

  1. Replaced Runtime.getRuntime().exec() with ProcessBuilder:

    • Ensures better control over external process execution.
    • Provides a more robust and modern approach to handling commands.
  2. Updated Affected Methods and Classes:

    • NetAdapterSim Constructor: Replaced exec() with ProcessBuilder for starting processes.
    • readManufacturerEmsSerialNumber: Updated to use ProcessBuilder for executing the hostname command.
    • Other minor adjustments to maintain consistency across the codebase.
  3. Maintained Existing Functionality:

    • Preserved fallback mechanisms, such as using InetAddress.getLocalHost().getHostName() for retrieving the hostname when the command execution fails.
    • All logic was retained to avoid functional regressions.
  4. Tested and Validated:

    • Verified that all updated methods behave as expected and that no functionality is broken due to the migration.

Please review the changes and provide feedback.

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 17.39130% with 19 lines in your changes missing coverage. Please review.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #2922      +/-   ##
=============================================
- Coverage      56.63%   56.62%   -0.00%     
+ Complexity      9504     9500       -4     
=============================================
  Files           2251     2251              
  Lines          96038    96049      +11     
  Branches        7090     7090              
=============================================
- Hits           54378    54375       -3     
- Misses         39659    39674      +15     
+ Partials        2001     2000       -1     

@sfeilmeier sfeilmeier merged commit d4d0df4 into OpenEMS:develop Dec 13, 2024
4 of 7 checks passed
@Sn0w3y Sn0w3y deleted the deprecation-fix-java21 branch December 13, 2024 13:06
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.

2 participants