mirror of https://github.com/apache/cloudstack.git
console-proxy: fix potential NPE condition (#3419)
When checking if the console proxy URL domain starts with *, the code does not check if the provided string is null. When domain is not configured the IP address should be used. Fixes #3164 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
6784cc516b
commit
2c3c88e209
|
|
@ -55,18 +55,16 @@ public class ConsoleProxyInfo {
|
|||
|
||||
private String formatProxyAddress(String consoleProxyUrlDomain, String proxyIpAddress) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
// Domain in format *.example.com, proxy IP is 1.2.3.4 --> 1-2-3-4.example.com
|
||||
if (consoleProxyUrlDomain.startsWith("*")) {
|
||||
if (StringUtils.isBlank(consoleProxyUrlDomain)) {
|
||||
// Blank config, we use the proxy IP
|
||||
sb.append(proxyIpAddress);
|
||||
} else if (consoleProxyUrlDomain.startsWith("*")) {
|
||||
// Domain in format *.example.com, proxy IP is 1.2.3.4 --> 1-2-3-4.example.com
|
||||
sb.append(proxyIpAddress.replaceAll("\\.", "-"));
|
||||
sb.append(consoleProxyUrlDomain.substring(1)); // skip the *
|
||||
|
||||
// Otherwise we assume a valid domain if config not blank
|
||||
} else if (StringUtils.isNotBlank(consoleProxyUrlDomain)) {
|
||||
sb.append(consoleProxyUrlDomain);
|
||||
|
||||
// Blank config, we use the proxy IP
|
||||
} else {
|
||||
sb.append(proxyIpAddress);
|
||||
// Otherwise we assume a valid domain if config not blank
|
||||
sb.append(consoleProxyUrlDomain);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue