It works for Collections. See #9290

Comment From: mbhave

Actually, maybe this is expected behavior since for collections we replace the entire collection but for Maps we merge.

Comment From: philwebb

Feels like we should be able to do something similar to the #9290 fix.

Comment From: wilkinsona

@bismaya123 It's difficult to offer any insight based on a single line from a stack trace, but you appear to be trying to add an entry to an immutable map. Without knowing more about that map – whether you created it or retrieved it from somewhere else – I can't say what you need to do to fix your problem. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements so please follow up on Stack Overflow or Gitter.

Comment From: bismaya123

@wilkinsona thanks for quick response, yes it is retrieved for Spring Boot 2.3.1. java.lang.UnsupportedOperationException: null at java.util.Collections$UnmodifiableMap.put(Collections.java:1459).

I'm using MapPropertySource, which is internally generating an immutable map, where as in 2.0.0 its internally generating a LinkedHashMap.

Comment From: wilkinsona

Knowing that it's a MapPropertySource doesn't help I'm afraid. A MapPropertySource uses whatever Map it is created with. Without knowing which MapPropertySource you are trying to mutate, we can only guess at what is happening and why.

This issue is about binding properties from the environment to a @ConfigurationProperties class that contains an immutable map whereas the problem that you are seeing is to do with mutating a property source in the environment. As such, your problem is unrelated to this issue and this isn't the right place to discuss it. As I said above, please follow up on Stack Overflow or Gitter. Or, if you believe you have found a bug, please open a new issue and provide a complete and minimal example that reproduces the problem.