Skip to content

Commit 1f14e00

Browse files
committed
refactor(core): Always return false in cred check util method on null input
1 parent 0899f12 commit 1f14e00

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/src/main/java/com/ibm/watson/developer_cloud/util/CredentialUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,18 @@ private CredentialUtils() {
164164
}
165165

166166
/**
167-
* Returns true if the supplied value begins or ends with curly brackets or quotation marks.
167+
* Returns true if the supplied value begins or ends with curly brackets or quotation marks. Returns false for null
168+
* inputs.
168169
*
169170
* @param credentialValue the credential value to check
170171
* @return true if the value starts or ends with these characters and is therefore invalid
171172
*/
172173
public static boolean hasBadStartOrEndChar(String credentialValue) {
173-
return credentialValue.startsWith("{")
174+
return credentialValue != null
175+
&& (credentialValue.startsWith("{")
174176
|| credentialValue.startsWith("\"")
175177
|| credentialValue.endsWith("}")
176-
|| credentialValue.endsWith("\"");
178+
|| credentialValue.endsWith("\""));
177179
}
178180

179181
// VCAP-related methods

0 commit comments

Comments
 (0)