Skip to content

Commit 06d870b

Browse files
committed
Do not wrap CF JSON Keys containing special characters
This reverts commit 6828a15. The commit has been reverted as it breaks backwards compatiblity. Fixes gh-20343
1 parent c5344b5 commit 06d870b

File tree

2 files changed

+0
-35
lines changed

2 files changed

+0
-35
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
*
8888
* @author Dave Syer
8989
* @author Andy Wilkinson
90-
* @author Madhura Bhave
9190
* @since 1.3.0
9291
*/
9392
public class CloudFoundryVcapEnvironmentPostProcessor
@@ -231,19 +230,7 @@ private String getPropertyName(String path, String key) {
231230
if (key.startsWith("[")) {
232231
return path + key;
233232
}
234-
if (shouldWrap(key)) {
235-
return path + "[" + key + "]";
236-
}
237233
return path + "." + key;
238234
}
239235

240-
private boolean shouldWrap(String key) {
241-
for (char ch : key.toCharArray()) {
242-
if (!Character.isLowerCase(ch) && !Character.isDigit(ch) && ch != '-') {
243-
return true;
244-
}
245-
}
246-
return false;
247-
}
248-
249236
}

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/cloud/cloudfoundry/CloudFoundryVcapEnvironmentPostProcessorTests.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
*
3131
* @author Dave Syer
3232
* @author Andy Wilkinson
33-
* @author Hans Schulz
34-
* @author Madhura Bhave
3533
*/
3634
public class CloudFoundryVcapEnvironmentPostProcessorTests {
3735

@@ -119,26 +117,6 @@ public void testServicePropertiesWithoutNA() {
119117
assertThat(getProperty("vcap.services.mysql.credentials.port")).isEqualTo("3306");
120118
}
121119

122-
@Test
123-
public void testServicePropertiesContainingKeysWithDot() {
124-
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context,
125-
"VCAP_SERVICES={\"user-provided\":[{\"name\":\"test\",\"label\":\"test-label\","
126-
+ "\"credentials\":{\"key.with.dots\":\"some-value\"}}]}");
127-
this.initializer.postProcessEnvironment(this.context.getEnvironment(), null);
128-
assertThat(getProperty("vcap.services.test.name")).isEqualTo("test");
129-
assertThat(getProperty("vcap.services.test.credentials[key.with.dots]")).isEqualTo("some-value");
130-
}
131-
132-
@Test
133-
public void testServicePropertiesContainingKeysWithUpperCaseAndNonAlphaNumericCharacters() {
134-
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context,
135-
"VCAP_SERVICES={\"user-provided\":[{\"name\":\"test\",\"label\":\"test-label\","
136-
+ "\"credentials\":{\"My-Key\":\"some-value\", \"foo@\":\"bar\"}}]}");
137-
this.initializer.postProcessEnvironment(this.context.getEnvironment(), null);
138-
assertThat(getProperty("vcap.services.test.credentials[My-Key]")).isEqualTo("some-value");
139-
assertThat(getProperty("vcap.services.test.credentials[foo@]")).isEqualTo("bar");
140-
}
141-
142120
private String getProperty(String key) {
143121
return this.context.getEnvironment().getProperty(key);
144122
}

0 commit comments

Comments
 (0)