We just upgraded our project from Spring Boot 2.1.7.RELEASE to 2.2.5.RELEASE.
Since we're using Cloud Foundry, we create our own Configurations for credentials with a @ConfigurationProperties
-Annotation.
Our VCAP Environment looks similar to this:
{
"VCAP_SERVICES": {
"aws_documentdb": [
{
"binding_name": null,
"credentials": {
"account": "123456789",
"ca_cert": "https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem",
"endpoint": "docdb-with-identifier.eu-west-1.docdb.amazonaws.com",
"instance_identifier": "d1234567890-12345671-12351",
"password": "password",
"port": 27017,
"reader-endpoint": "docdb-with-identifier-reader.eu-west-1.docdb.amazonaws.com",
"url": "mongodb://user:password@ocdb-with-identifier.eu-west-1.docdb.amazonaws.com:27017/admin?ssl=true",
"user": "user"
}
"instance_name": "asdcs-document-db",
"label": "aws_documentdb",
"name": "asdcs-document-db"
}
]
}
}
Before Spring Boot 2.2.5.RELEASE this would result in the following properties:
...
vcap.services.asdcs-document-db.credentials.account = 123456789
vcap.services.asdcs-document-db.credentials.endpoint = docdb-with-identifier.eu-west-1.docdb.amazonaws.com
vcap.services.asdcs-document-db.credentials.ca_cert = https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
vcap.services.asdcs-document-db.credentials.instance_identifier = d1234567890-12345671-12351
vcap.services.asdcs-document-db.credentials.reader-endpoint = docdb-with-identifier-reader.eu-west-1.docdb.amazonaws.com
...
The @ConfigurationProperties
-annotated class would work fine:
@Configuration
@ConfigurationProperties("vcap.services.asdcs-document-db.credentials")
public class CloudFoundryAwsDocumentDbCredentials {
String caCert; //equals https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
String endpoint; /
String instanceIdentifier; //equals d1234567890-12345671-12351
String password;
int port;
String readerEndpoint; //equals docdb-with-identifier-reader.eu-west-1.docdb.amazonaws.com
String url;
String user;
}
With 2.2.5.RELEASE a wrapping was implemented inside the CloudFoundryVcapEnvironmentPostProcessor's getPropertyName(...)
and shouldWrap(...)
-methods (commited at 544dca7).
This breaks the CloudFoundryAwsDocumentDbCredentials @ConfigurationProperties
functionality. All mapped fields of the wrapped properties are not automatically populated.
...
vcap.services.asdcs-document-db.credentials.account = 123456789
vcap.services.asdcs-document-db.credentials.endpoint = docdb-with-identifier.eu-west-1.docdb.amazonaws.com
vcap.services.asdcs-document-db.credentials.[ca_cert] = https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
vcap.services.asdcs-document-db.credentials.[instance_identifier] = d1234567890-12345671-12351
vcap.services.asdcs-document-db.credentials.[reader-endpoint] = docdb-with-identifier-reader.eu-west-1.docdb.amazonaws.com
...
@Configuration
@ConfigurationProperties("vcap.services.asdcs-document-db.credentials")
public class CloudFoundryAwsDocumentDbCredentials {
String caCert; // is null
String instanceIdentifier; //is null
...
String readerEndpoint; //is null
...
}
The properties that are not wrapped are working fine, though.
Comment From: wilkinsona
Thanks for the report and sorry for the inconvenience. This is a duplicate of #20343. Please feel free to add your findings to that issue.