Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-cfenv-boot Newline Bug Reproduction

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.

The Bug

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

Branches

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

Running the Tests

# Spring Boot 3 - should pass
git checkout spring-boot-3
mvn test

# Spring Boot 4 - should fail
git checkout spring-boot-4
mvn test

Test Layers

The tests verify newline handling at four different layers:

  1. Layer 1: Raw Environment - System.getenv("VCAP_SERVICES") parsed with Jackson
  2. Layer 2: CfEnv API - cfEnv.findServiceByName(...).getCredentials().getString(...)
  3. Layer 3: Spring Environment - environment.getProperty("vcap.services.*.credentials.*")
  4. Layer 4: @Value Injection - @Value("${vcap.services.*.credentials.*}")

Expected Results

Spring Boot 3 + java-cfenv-boot 3.5.1

All layers return identical values with actual newline characters (byte 10).

Spring Boot 4 + java-cfenv-boot 4.0.0

  • 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')

Workaround

Use the CfEnv API directly instead of Spring property binding:

CfEnv cfEnv = new CfEnv();
String pemKey = cfEnv.findServiceByName("my-service")
    .getCredentials()
    .getString("private_key");

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages