This repository demonstrates a regression in java-cfenv-boot 4.0.0 where newline characters in VCAP_SERVICES credential values are corrupted when accessed via Spring's Environment or @Value injection.
When java-cfenv-boot 4.0.0 registers vcap.services.* properties with Spring Boot 4, newline characters (byte 10) in property values are converted to literal 'n' characters (byte 110).
This breaks any credential containing newlines, such as:
- PEM certificates and private keys
- Multi-line configuration strings
- SSH keys
| Branch | Spring Boot | java-cfenv-boot | Result |
|---|---|---|---|
spring-boot-3 |
3.5.x | 3.5.1 | All tests pass |
spring-boot-4 |
4.0.x | 4.0.0 | Layer 3 & 4 tests fail |
# Spring Boot 3 - should pass
git checkout spring-boot-3
mvn test
# Spring Boot 4 - should fail
git checkout spring-boot-4
mvn testThe tests verify newline handling at four different layers:
- Layer 1: Raw Environment -
System.getenv("VCAP_SERVICES")parsed with Jackson - Layer 2: CfEnv API -
cfEnv.findServiceByName(...).getCredentials().getString(...) - Layer 3: Spring Environment -
environment.getProperty("vcap.services.*.credentials.*") - Layer 4: @Value Injection -
@Value("${vcap.services.*.credentials.*}")
All layers return identical values with actual newline characters (byte 10).
- Layer 1 (raw env): PASS - byte 10 (actual newline)
- Layer 2 (CfEnv API): PASS - byte 10 (actual newline)
- Layer 3 (Spring Environment): FAIL - byte 110 (literal 'n')
- Layer 4 (@Value): FAIL - byte 110 (literal 'n')
Use the CfEnv API directly instead of Spring property binding:
CfEnv cfEnv = new CfEnv();
String pemKey = cfEnv.findServiceByName("my-service")
.getCredentials()
.getString("private_key");