spring-cloud / spring-cloud/spring-cloud-config
Yml endpoint error
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2k
- Forks
- 1.3k
- Avg merge
- 2d 59m
- Merged PRs (30d)
- 16
Description
Config server build from initiazer using spring-boot-starter-parent:2.0.4.RELEASE.
Having these files packed into an app and run with native profile.
$ cat src/main/resources/config/foo.properties
foo: from foo props
democonfigclient.message: hello spring io
$ cat src/main/resources/config/foo-db.properties
foo.db: mycooldb
$ cat src/main/resources/config/foo-development.properties
bar: spam
foo: from foo development
$ cat src/main/resources/config/foo-development-db.properties
combined: true
Using properties endpoint works but yml errors out:
$ curl localhost:8888/foo-db.properties
democonfigclient.message: hello spring io
foo: from foo props
foo.db: mycooldb
$ curl localhost:8888/foo-db.yml
{"timestamp":"2018-08-20T07:01:13.249+0000","status":500,"error":"Internal Server Error","message":"java.lang.String cannot be cast to java.util.Map","path":"/foo-db.yml"}
With error on a server side.
2018-08-20 10:01:13.247 ERROR 19223 --- [nio-8888-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map] with root cause
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
at org.springframework.cloud.config.server.environment.EnvironmentController$PropertyNavigator.setMapValue(EnvironmentController.java:367) ~[spring-cloud-config-server-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]
at org.springframework.cloud.config.server.environment.EnvironmentController$PropertyNavigator.access$100(EnvironmentController.java:349) ~[spring-cloud-config-server-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]
at org.springframework.cloud.config.server.environment.EnvironmentController.convertToMap(EnvironmentController.java:240) ~[spring-cloud-config-server-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]
at org.springframework.cloud.config.server.environment.EnvironmentController.labelledYaml(EnvironmentController.java:204) ~[spring-cloud-config-server-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]
at org.springframework.cloud.config.server.environment.EnvironmentController.yaml(EnvironmentController.java:193) ~[spring-cloud-config-server-2.0.1.RELEASE.jar!/:2.0.1.RELEASE]
Maybe we should handle these cases with yml where we have foo and foo.db in props.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at EnvironmentController.yaml and its convertToMap/setMapValue methods, identified by the stack trace, and reproduce the failure with the foo-db.yml endpoint using the shown property files. The work is done when YAML output handles overlapping foo and foo.db properties without a ClassCastException and retains the expected values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100