Skip to content

Fix bug: Put a value into Collections.emptyMap(). - #31379

Merged
chenrujun merged 12 commits into
Azure:mainfrom
chenrujun:issue_31190_put-a_value_into_Collections.emptyMap
Oct 12, 2022
Merged

Fix bug: Put a value into Collections.emptyMap().#31379
chenrujun merged 12 commits into
Azure:mainfrom
chenrujun:issue_31190_put-a_value_into_Collections.emptyMap

Conversation

@chenrujun

@chenrujun chenrujun commented Oct 11, 2022

Copy link
Copy Markdown

Fix #31190

Root cause analysis

  1. This bug is first introduced in this commit: a79493d
    image

How to fix

  1. Immutable as default. When get an object from another method, assume the object is immutable. If modification is necessary, create a new object then modify the new object. Doing like this will make code more robust. Discard this, because Immutable as default has extra costs. Use java doc to specify whether the object is mutable or not.
  2. Add unit test.

Learn (How to avoid similar problem in the future)

  1. Follow TDD (Test Driven Development).
  2. Follow Immutable as default principal. Discard this, because Immutable as default has extra costs. Use java doc to specify whether the object is mutable or not.

Extra information

RestTemplateBuilder followed Immutable as default principal: In each build step, it creates a new RestTemplateBuilder instead of using setter. Here is screenshot:
image

@ghost ghost added the azure-spring All azure-spring related issues label Oct 11, 2022
@chenrujun chenrujun self-assigned this Oct 11, 2022
@chenrujun chenrujun added Client This issue points to a problem in the data-plane of the library. bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Oct 11, 2022
@chenrujun chenrujun added this to the 2022-11 milestone Oct 11, 2022
@azure-sdk

Copy link
Copy Markdown
Collaborator

API change check

API changes are not detected in this pull request.

@chenrujun
chenrujun force-pushed the issue_31190_put-a_value_into_Collections.emptyMap branch from d5e54ae to a3a8499 Compare October 11, 2022 09:25
@chenrujun
chenrujun force-pushed the issue_31190_put-a_value_into_Collections.emptyMap branch from 66ae153 to 4f75d30 Compare October 12, 2022 06:49
@chenrujun
chenrujun merged commit 8d4caa2 into Azure:main Oct 12, 2022
@chenrujun
chenrujun deleted the issue_31190_put-a_value_into_Collections.emptyMap branch October 12, 2022 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure-spring All azure-spring related issues bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] v.4.4.0-beta.1: Put a value into Collections.emptyMap - JacksonHttpSessionOAuth2AuthorizedClientRepository

5 participants