Example
I created a simple app w/ the following config props:
@ConfigurationProperties(prefix = "foo")
public class TestConfigProps {
/**
* Paths of things
*/
private List<File> paths = new ArrayList<>(Collections.singletonList(new File(".")));
public List<File> getPaths() {
return paths;
}
public void setPaths(final List<File> paths) {
this.paths = paths;
}
}
Warn Mode
- I ran the config processor which output the following:
- I then added the following hint:
json { "properties": [ { "name": "foo.paths", "type": "java.util.List<java.io.File>", "defaultValue": [ "." ] } ] } - I ran the config processor again - problem fixed:
Fail Mode
When using "fail mode" its the same as above w/ the exception of the problem output looking like the following:
TODOS
- [ ] add ability to disable error mode??
- [ ] add test for configprocessor validation checks
- [ ] docs?
Fixes gh-28039
Comment From: snicoll
@bono007 do you have an update for us? If you don't, no worries, we can pick things up as they are as RC1 is our last chance to include this in 2.6.
Comment From: onobc
Hi @snicoll - things got busy on my end but I have carved out some time this morning to work on this.
To help me gauge if this needs to be done in "a day" or "the next few days", is 10/21 still accurate?
I will give an update (code or no code) by today @ "12:00:00 -5:00" (~5hrs from time of writing)
Comment From: snicoll
Thanks for the follow-up Chris. Yeah that's the RC1 release date so we still have plenty of time. Please do not rush it and let us know if you have any question.
Comment From: onobc
Thanks for the follow-up Chris. Yeah that's the RC1 release date so we still have plenty of time. Please do not rush it and let us know if you have any question.
@snicoll my plans to carve out time this morning were foiled by a Kafka Streams production outage that I am putting out. It sounds though it is ok to have something in the next 1-2 days is ok though (correct me if that is not the case). I should have time later today to get back to it.
Thanks
Comment From: onobc
@snicoll I was looking through the build failures and our update to the processor is suggesting that we have quite a few "hints" to add ourselves...
```java
Task :spring-boot-project:spring-boot-autoconfigure:compileJava FAILED error: Could not resolve default value for property 'server.tomcat.additional-tld-skip-patterns' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'server.tomcat.relaxed-path-chars' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'server.tomcat.relaxed-query-chars' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'server.undertow.accesslog.dir' using expression 'new File("logs")'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'server.undertow.max-headers' using expression 'UndertowOptions.DEFAULT_MAX_HEADERS'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'server.undertow.max-parameters' using expression 'UndertowOptions.DEFAULT_MAX_PARAMETERS'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'server.undertow.options.server' using expression 'new LinkedHashMap<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'server.undertow.options.socket' using expression 'new LinkedHashMap<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.activemq.packages.trusted' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.artemis.embedded.cluster-password' using expression 'UUID.randomUUID().toString()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.artemis.embedded.server-id' using expression 'serverIdCounter.getAndIncrement()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.cache.cache-names' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.data.elasticsearch.client.reactive.endpoints' using expression 'new ArrayList<>(Collections.singletonList("localhost:9200"))'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.datasource.xa.properties' using expression 'new LinkedHashMap<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.flyway.init-sqls' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.flyway.jdbc-properties' using expression 'new HashMap<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.flyway.placeholders' using expression 'new HashMap<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.flyway.schemas' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.freemarker.settings' using expression 'new HashMap<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.integration.channel.max-broadcast-subscribers' using expression 'Integer.MAX_VALUE'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.integration.channel.max-unicast-subscribers' using expression 'Integer.MAX_VALUE'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.integration.endpoint.no-auto-startup' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.integration.endpoint.read-only-headers' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.jersey.init' using expression 'new HashMap<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.jpa.properties' using expression 'new HashMap<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.kafka.bootstrap-servers' using expression 'new ArrayList<>(Collections.singletonList("localhost:9092"))'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.kafka.consumer.key-deserializer' using expression 'StringDeserializer.class'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.kafka.consumer.value-deserializer' using expression 'StringDeserializer.class'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.kafka.producer.key-serializer' using expression 'StringSerializer.class'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.kafka.producer.value-serializer' using expression 'StringSerializer.class'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.ldap.embedded.base-dn' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.mail.properties' using expression 'new HashMap<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.mvc.contentnegotiation.media-types' using expression 'new LinkedHashMap<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.rabbitmq.stream.port' using expression 'DEFAULT_STREAM_PORT'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.security.user.password' using expression 'UUID.randomUUID().toString()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.security.user.roles' using expression 'new ArrayList<>()'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.session.servlet.filter-order' using expression 'SessionRepositoryFilter.DEFAULT_ORDER'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.task.execution.pool.max-size' using expression 'Integer.MAX_VALUE'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.task.execution.pool.queue-capacity' using expression 'Integer.MAX_VALUE'. Add hint in additional-spring-configuration.metadata.json error: Could not resolve default value for property 'spring.webservices.servlet.init' using expression 'new HashMap<>()'. Add hint in additional-spring-configuration.metadata.json 40 errors ```` I will start marching through the above list and will add these to the additional metadata.
Comment From: onobc
When I encountered the above list I was a bit surprised - I did not expect to see so many entries in violation. I am thinking we should leave the default behavior as Kind.ERROR but provide the ability to switch to Kind.WARN. In most cases I bet the list of updates needed is small but I am sure there are some cases where this will be a pain to absorb at once. Thoughts?
Comment From: snicoll
Thanks for the follow-up.
I did not expect to see so many entries in violation.
There are a lot of false positive in this list. Creating an empty list or map shouldn't lead to a violation. UUID.randomUUID().toString() on the default security password is interesting. We'd probably need a way to escape that check.
Comment From: onobc
Thanks for the follow-up.
Np.
There are a lot of false positive in this list. Creating an empty list or map shouldn't lead to a violation.
UUID.randomUUID().toString()on the default security password is interesting. We'd probably need a way to escape that check.
I will add these exemptions and then add "hints" for the remaining entries.
Comment From: wilkinsona
Thanks, @onobc. Unfortunately, having seen what it takes to implement it we've realised that my initial idea wasn't a particularly good one. I'm afraid we're going to decline this and try some alternatives idea. Sorry for the wasted effort. We'll repurpose #28039 to do that.
Comment From: onobc
@wilkinsona no worries - we try some approaches and some work and some don't. :)