Hi Team, I was trying to upgrade my application to spring boot 2.3.1, got issue -java.lang.UnsupportedOperationException: null at java.util.Collections$UnmodifiableMap.put(Collections.java:1459) in my postprocessenvironment class. please give me some insight.
Comment From: bclozel
Could you provide us with a sample application that reproduces the issue? Your comment doesn't give us enough information to look into this.
Thanks!
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: bismaya123
Hi Team, i have resolved the issue, Thanks @bclozel for your prompt response.it was having some properties file issue, so I did resolve on that day. @spring-issuemaster please go ahead and close the issue.
Comment From: caiqichang
@bismaya123 could you tell how to deal with it ? i got this problem too
Comment From: bismaya123
Hi @caiqichang, you get this type of error, when you try to write something to a read only properties file during deployment. if you are using build-info properties to read service-name and service-version etc. through a config class, avoid doing that so, try to read all those information from application properties directly rather than modifying properties file. hope this will resolve this problem.
Comment From: caiqichang
@bismaya123 thank you. i found i should override the properties instead of modifying them. some code like:
public class EnvironmentPostProcessorConfig implements EnvironmentPostProcessor {
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
// ...
environment.getPropertySources().addFirst(new MapPropertySource(...));
}
}