Flux/Mono.usingWhen late resource memory leak (#3695)
UsingWhen method may lead to a memory or resource leak of allocation was finished after the main pipeline was cancelled. This change assures that asyncCancel is always called even if deferred.
Fixes #3695.
@mlozbin Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
@mlozbin Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
@mlozbin Thank you for signing the Contributor License Agreement!
Thank you @mlozbin for the effort. Unfortunately, as highlighted in my comment in the original issue, this PR breaks existing functionality and can't be accepted in the current form. Let's work through the design first and decide if a change in the code is necessary.
I reopened the PR hoping to run the CI and prove a point raised in the original issue, but there are two problems:
- The PR fails the preliminary tests due to not having the license headers updated (
./gradlew spotlessApplyfixes that) - There are failing tests and removed tests which should remain in the codebase.
Most importantly, this PR removes tests that validate functionality that currently is supported. Perhaps not in a documented way, but this behaviour can be something users out there rely on. So this change can't go in a patch release and definitely not without a documented migration path. Luckily, while the removal happened in MonoUsingWhenTest class, they are still present in FluxUsingWhenTest class and fail with this PR:
-
FluxUsingWhenTest > lateFluxResourcePublisherIsCancelledOnCancel() -
FluxUsingWhenTest > lateMonoResourcePublisherIsCancelledOnCancel()
In summary, in the current form, I'm discarding this PR, but I remain open to discussing the plan for both solving the issue you describe while giving the existing usage patterns either a migration path or keeping the current behaviour supported (my preferred option). Thank you @mlozbin for the work you did so far and I look forward to constructive discussion in the original issue.