Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix double release of form attributes
Attributes returned by `postRequestDecoder.next()` are released twice when the decoder is destroyed: - Once because it's stored in the `bodyListHttpData` list - A second time because the `HttpDataFactory` keeps a copy around. This means that even if user code retains the attribute in question once, it may still be collected. In the test case, this issue is visible because the attribute is only parsed to a map later downstream in an IO thread, when the `FormDataHttpContentProcessor` has already completed. This patch uses `removeHttpDataFromClean` to avoid the duplicate release for HTTP data where it could happen. `removeHttpDataFromClean` is a no-op for data that isn't created by the `HttpDataFactory`, so this patch doesn't break in those cases. This patch risks exposing downstream buffer leaks: If the user code doesn't properly release attributes it retains, they would previously still have been collected because of this duplicate release. After this change, they may leak, potentially even leaving files on disk. However, imo this patch implements the "right" behavior, and we should deal with other issues as they appear. I've done some testing, but it's inconclusive. I ran `./gradlew check` with and without this patch, and in both cases, attribute files were retained in `/tmp`. Can't tell whether this patch introduced new leaks. Addresses #6705
- Loading branch information