Describe the bug
Spring Cloud Config 2.2.5.RELEASE
I have an issue with the following configuration. The use of "[
is due to the >
in the property name:
dms:
standardization:
rules:
"[XXX>yyy]":
- XXX>www
An exception is thrown:
java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class java.util.List (java.util.LinkedHashMap and java.util.List are in module java.base of loader 'bootstrap')
at org.springframework.cloud.config.server.environment.EnvironmentController$PropertyNavigator.setMapValue(EnvironmentController.java:375)
at org.springframework.cloud.config.server.environment.EnvironmentController$PropertyNavigator.setMapValue(EnvironmentController.java:372)
at org.springframework.cloud.config.server.environment.EnvironmentController$PropertyNavigator.setMapValue(EnvironmentController.java:372)
at org.springframework.cloud.config.server.environment.EnvironmentController$PropertyNavigator.access$100(EnvironmentController.java:349)
at org.springframework.cloud.config.server.environment.EnvironmentController.convertToMap(EnvironmentController.java:240)
at org.springframework.cloud.config.server.environment.EnvironmentController.labelledYaml(EnvironmentController.java:204)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
By debugging the code, I see that the propertyKey
is converted to dms.standardization.rules[XXX>yyy][0]
which results in an IllegalArgumentException
because the character after a square bracket is supposed to be a digit
https://github.com/spring-cloud/spring-cloud-config/blob/cec480ea2dfdf819dde95479d07e186b6ecc5f7d/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/EnvironmentController.java#L463
Comment From: spencergibb
Yes. It's not meant to be exhaustive because of incompatibilities between yaml and properties. If you can think of a fix that would be great, otherwise we'll see if there are others suffering from this issue.
Comment From: gbfvip
same issue here when try to define some cors configs for spring cloud gateway, the config I try to use is:
spring:
cloud:
gateway:
enabled: true
globalcors:
cors-configurations:
'[/**]':
allowedOrigins: "*"
allowedHeaders: "*"
allowedMethods: "*"
allowCredentials: true