Skip to content

do not mutate the input map in switch closure/transformer factories#700

Open
rootvector2 wants to merge 1 commit into
apache:masterfrom
rootvector2:switch-factory-input-map-copy
Open

do not mutate the input map in switch closure/transformer factories#700
rootvector2 wants to merge 1 commit into
apache:masterfrom
rootvector2:switch-factory-input-map-copy

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

switchClosure(Map), switchMapClosure(Map) and switchMapTransformer(Map) pulled the default out with map.remove(null) on the caller's map, so the null-key entry vanished from the caller's map as a side effect; spotted while extending the sibling fix in #696 that only touched SwitchTransformer.switchTransformer, they now copy into a LinkedHashMap first.

@garydgregory

Copy link
Copy Markdown
Member

Hello @rootvector2
Thank you for the PR.

Please update the tests here and the new one from #696 to also make sure the result from calling the various switch*() is valid.

Even though we might have other tests that do so, seeing a simple check in these new tests give me more confidence that there are no unintended side-effects.

TY!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants