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

Use try-with-resources to properly close streams #7274

Merged
merged 3 commits into from
Jul 19, 2023

Conversation

mackdk
Copy link
Contributor

@mackdk mackdk commented Jul 17, 2023

What does this PR change?

This PR fixes some sonarcloud bugs by using try-with-resources to address simple cases of streams not properly closed.

GUI diff

No difference.

  • DONE

Documentation

  • No documentation needed: only internal and user invisible changes

  • DONE

Test coverage

  • No tests: already covered

  • DONE

Changelogs

Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository

If you don't need a changelog check, please mark this checkbox:

  • No changelog needed

If you uncheck the checkbox after the PR is created, you will need to re-run changelog_test (see below)

Re-run a test

If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:

  • Re-run test "changelog_test"
  • Re-run test "backend_unittests_pgsql"
  • Re-run test "java_pgsql_tests"
  • Re-run test "schema_migration_test_pgsql"
  • Re-run test "susemanager_unittests"
  • Re-run test "javascript_lint"
  • Re-run test "spacecmd_unittests"

@github-actions
Copy link
Contributor

Suggested tests to cover this Pull Request
  • srv_monitoring
  • proxy_cobbler_pxeboot
  • srv_rename_hostname
  • proxy_branch_network
  • srv_first_settings
  • proxy_as_pod_basic_tests
  • allcli_sanity
  • min_salt_formulas
  • min_deblike_ssh
  • min_ssh_tunnel
  • srv_power_management_redfish
  • minssh_salt_install_package
  • allcli_software_channels_dependencies
  • min_change_software_channel
  • min_monitoring
  • min_action_chain
  • srv_distro_cobbler
  • allcli_reboot
  • min_deblike_salt
  • min_timezone
  • minssh_action_chain
  • min_salt_minion_details
  • min_bootstrap_script
  • sle_ssh_minion
  • sle_minion
  • allcli_overview_systems_details
  • min_cve_id_new_syntax
  • min_rhlike_openscap_audit
  • min_move_from_and_to_proxy
  • min_rhlike_monitoring
  • srv_scc_user_credentials
  • allcli_action_chain
  • min_bootstrap_reactivation
  • srv_cobbler_profile
  • min_salt_install_package
  • min_check_patches_install
  • min_deblike_salt_install_package
  • min_rhlike_salt
  • min_bootstrap_api
  • srv_reportdb
  • min_rhlike_ssh
  • buildhost_docker_build_image
  • min_config_state_channel_subscriptions
  • min_salt_openscap_audit
  • proxy_register_as_minion_with_script
  • min_bootstrap_ssh_key
  • min_deblike_openscap_audit
  • allcli_software_channels
  • min_salt_minions_page
  • min_recurring_action
  • min_salt_mgrcompat_state
  • srv_advanced_search
  • min_deblike_salt_install_with_staging
  • min_rhlike_salt_install_package_and_patch
  • minssh_ansible_control_node
  • min_project_lotus
  • minkvm_guests
  • proxy_retail_pxeboot_and_mass_import
  • min_activationkey
  • srv_cobbler_distro
  • srv_power_management
  • srv_docker_cve_audit
  • min_deblike_monitoring
  • min_salt_user_states
  • minssh_move_from_and_to_proxy
  • buildhost_bootstrap
  • min_salt_formulas_advanced
  • allcli_config_channel
  • min_salt_lock_packages
  • min_salt_install_with_staging
  • min_virthost
  • minssh_bootstrap_api
  • min_ansible_control_node
  • min_empty_system_profiles
  • min_config_state_channel
  • allcli_system_group
  • min_retracted_patches
  • min_salt_pkgset_beacon
  • buildhost_osimage_build_image
  • srv_maintenance_windows
  • min_custom_pkg_download_endpoint
  • min_salt_software_states
  • min_cve_audit
  • srv_handle_software_channels_with_ISS_v2
  • srv_create_activationkey
  • srv_sync_products
  • srv_menu
  • srv_notifications
  • srv_payg_ssh_connection
  • min_rhlike_remote_command
  • srv_security
  • srv_delete_channel_with_tool
  • srv_docker
  • srv_check_reposync
  • min_config_state_channel_api
  • srv_clone_channel_npn
  • srv_restart
  • srv_create_repository
  • srv_patches_page
  • min_deblike_remote_command
  • srv_disable_local_repos_off
  • srv_channel_api
  • srv_menu_filter
  • srv_change_password
  • srv_osimage
  • buildhost_docker_auth_registry
  • srv_push_package
  • srv_dist_channel_mapping
  • srv_datepicker
  • srv_change_task_schedule
  • srv_custom_system_info
  • min_bootstrap_negative
  • srv_task_status_engine
  • srv_activationkey_api
  • srv_logfile
  • srv_salt
  • srv_virtual_host_manager
  • srv_users
  • srv_wait_for_reposync
  • srv_user_preferences
  • srv_handle_config_channels_with_ISS_v2
  • srv_power_management_api
  • srv_delete_channel_from_ui
  • srv_content_lifecycle
  • srv_check_sync_source_packages
  • srv_check_channels_page
  • srv_group_union_intersection
  • srv_salt_download_endpoint
  • srv_add_rocky8_repositories
  • srv_channels_add
  • srv_manage_activationkey
  • srv_enable_sync_products
  • srv_sync_channels
  • allcli_update_activationkeys
  • srv_user_configuration_salt_states
  • srv_user_api
  • srv_organization_credentials
  • srv_cobbler_buildiso
  • srv_cobbler_sync
  • srv_docker_advanced_content_management
  • srv_mainpage
  • min_docker_api
  • srv_manage_channels_page

@mackdk mackdk requested a review from cbosdo July 17, 2023 11:20
Copy link
Contributor

@cbosdo cbosdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup!

@mackdk mackdk marked this pull request as ready for review July 18, 2023 10:15
@mackdk mackdk requested review from a team as code owners July 18, 2023 10:15
@mackdk mackdk requested review from cbbayburt and removed request for a team July 18, 2023 10:15
Copy link
Contributor

@cbbayburt cbbayburt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try-with-resources probably didn't even exist when this code was written :D

Thanks for the improvement 👍

@mackdk mackdk merged commit f01e06f into uyuni-project:master Jul 19, 2023
13 checks passed
@mackdk mackdk deleted the fix-unclosed-resources branch July 19, 2023 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants