镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Avoid closing response twice in toBodilessEntity - #37565

Open
guanchengang wants to merge 1 commit into
spring-projects:mainfrom
guanchengang:fix/to-bodiless-entity-double-close
Open

guanchengang wants to merge 1 commit into
spring-projects:mainfrom
guanchengang:fix/to-bodiless-entity-double-close

Conversation

@guanchengang

Copy link
Copy Markdown
Contributor

toBodilessEntity() wrapped the exchange function in try-with-resources, which closed the response inside the function. exchangeInternal() then closed the same response again in its finally block, since the default exchange call passes close=true.

Remove the try-with-resources from toBodilessEntity() and let exchangeInternal() own the response lifecycle.

Add a regression test asserting that the response is closed exactly once.

`toBodilessEntity()` wrapped the exchange function in try-with-resources,
which closed the response inside the function. `exchangeInternal()` then
closed the same response again in its finally block, since the default
exchange call passes close=true.

Remove the try-with-resources from `toBodilessEntity()` and let
`exchangeInternal()` own the response lifecycle.

Add a regression test asserting that the response is closed exactly
once.

Signed-off-by: Chengang Guan <guanchengang@qq.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants