Repository navigation
Conversation
If a nested filter's init() throws, the Servlet container will not call destroy() on the CompositeFilter. Previously, filters that had already been initialized were left without cleanup. Destroy those earlier filters in reverse order before rethrowing, and add any destroy() failures as suppressed exceptions. Do not destroy the filter whose init() failed, matching the Servlet specification. See spring-projectsgh-37445 Signed-off-by: lejuho <zedd1324@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Follow-up to #37445 / #37430.
CompositeFilter.init()initializes nested filters in order. If a later filter'sinitthrows, the Servlet container does not calldestroy()on the composite (the Servlet specification only invokesdestroyafter a successfulinit). Filters that had already been initialized were therefore left without cleanup.Changes
initfailure, destroy filters that were already initialized, in reverse order, before rethrowing.destroy()failures as suppressed exceptions on the original failure.destroy()on the filter whoseinitfailed.Testing
Added tests covering cleanup order, skipped destroy for the failing filter, suppressed destroy failures, and
RuntimeException/Errorfrominit.Result: BUILD SUCCESSFUL (Checkstyle passes).
Related
CompositeFilterdespite failures #37445 / Destroy all filters inCompositeFiltereven if one fails #37430: continue destroying remaining filters whendestroy()fails