Skip to content

Fix reference count to decrease correctly when initialization fails#122

Merged
mayuki merged 5 commits intomainfrom
feature/FixLeakedRefCountOnInitialization
Apr 22, 2025
Merged

Fix reference count to decrease correctly when initialization fails#122
mayuki merged 5 commits intomainfrom
feature/FixLeakedRefCountOnInitialization

Conversation

@mayuki
Copy link
Member

@mayuki mayuki commented Apr 22, 2025

No description provided.

@mayuki mayuki requested a review from Copilot April 22, 2025 05:45
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

The PR addresses an issue where the reference count is not decreased correctly when initialization fails. Key changes include:

  • Adding a new test (InitializationFailure) to verify that the reference count returns to zero even when initialization fails.
  • Refactoring the UDS test to employ using declarations for proper disposal.
  • Wrapping the native handler initialization in a try/catch block to ensure the runtime is released on exception.
  • A minor formatting update in NativeRuntime.cs.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/YetAnotherHttpHandler.Test/YetAnotherHttpHandlerTest.cs Adds pre-condition checks and a new test to cover initialization failure scenarios
test/YetAnotherHttpHandler.Test/UdsTest.cs Updates resource management using "using" statements to guarantee disposal
src/YetAnotherHttpHandler/NativeRuntime.cs Minor formatting update
src/YetAnotherHttpHandler/NativeHttpHandlerCore.cs Introduces a try/catch to release the runtime if initialization fails

@mayuki mayuki force-pushed the feature/FixLeakedRefCountOnInitialization branch from 8eb0fb6 to cd148d7 Compare April 22, 2025 09:20
@mayuki mayuki merged commit 876c155 into main Apr 22, 2025
14 checks passed
@mayuki mayuki deleted the feature/FixLeakedRefCountOnInitialization branch April 22, 2025 09:44
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