Commit 818d3bd2 authored by Ben Hale's avatar Ben Hale Committed by Phillip Webb

VcapApplicationListener Boolean Credentials

Previously, the VcapApplicationListener would discard any service
credential value that wasn't a String, Number, Map, Collection, or
null.  This was particularly a problem for services that exposed a
value as a JSON boolean.  This change takes booleans in the credential
payload into account, converting them to Strings so that they will
pass through the properties system properly.  There's no real downside
to this as Spring will coerce them back into Booleans if needed, by
the application.

Fixes gh-3237
parent 75ffd1b0
......@@ -211,6 +211,9 @@ public class VcapApplicationListener implements
else if (value instanceof Number) {
properties.put(key, value.toString());
}
else if (value instanceof Boolean) {
properties.put(key, value.toString());
}
else if (value instanceof Map) {
// Need a compound key
@SuppressWarnings("unchecked")
......
......@@ -111,12 +111,15 @@ public class VcapApplicationListenerTests {
+ "\"plan\":\"10mb\",\"credentials\":{"
+ "\"name\":\"d04fb13d27d964c62b267bbba1cffb9da\","
+ "\"hostname\":\"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com\","
+ "\"ssl\":true,\"location\":null,"
+ "\"host\":\"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com\","
+ "\"port\":3306,\"user\":\"urpRuqTf8Cpe6\",\"username\":"
+ "\"urpRuqTf8Cpe6\",\"password\":\"pxLsGVpsC9A5S\"}}]}");
this.initializer.onApplicationEvent(this.event);
assertEquals("mysql", getProperty("vcap.services.mysql.name"));
assertEquals("3306", getProperty("vcap.services.mysql.credentials.port"));
assertEquals("true", getProperty("vcap.services.mysql.credentials.ssl"));
assertEquals("", getProperty("vcap.services.mysql.credentials.location"));
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment