[core] Copy the branch list before adding the main branch in orphan clean - #10216
Open
LuciferYang wants to merge 2 commits into
Open
LuciferYang wants to merge 2 commits into
LuciferYang wants to merge 2 commits into
Conversation
…lean OrphanFilesClean.validBranches used the branch manager's returned list directly and appended the main branch to it. The REST branch manager serves Collections.emptyList() for a table without branches, so the add threw UnsupportedOperationException and aborted the orphan-files cleaning; a cached or otherwise shared list would be poisoned the same way. Copy the list before mutating it. Assisted-by: GLM-5.3
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.
Purpose
OrphanFilesClean.validBranchestook the list returned by the branch manager and appended the main branch to it in place. For a table without branches the REST branch manager returns an immutable empty list, sinceRESTApi.listBranchesfalls back toCollections.emptyList(), so the add threwUnsupportedOperationExceptionand aborted orphan file cleaning. A cached or otherwise shared list would be corrupted the same way. This copies the branch list into a newArrayListbefore adding the main branch.Tests
Added
OrphanFilesCleanTest.testValidBranchesDoesNotMutateManagerList. It mocks the branch manager to returnCollections.emptyList()and assertsvalidBranchesreturns exactly[main]. Without the fix this test errors withUnsupportedOperationException.API and Format
No.
Documentation
No.