console-proxy: fix potential NPE condition#3419
Conversation
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 apache#3164 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
| 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("*")) { |
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-20 |
|
@blueorangutan test |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
nvazquez
left a comment
There was a problem hiding this comment.
LGTM. Just minor code improvement
| 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 (consoleProxyUrlDomain != null && consoleProxyUrlDomain.startsWith("*")) { |
There was a problem hiding this comment.
Can we reorder this if-then-else? To:
if (StringUtils.isBlank(consoleProxyUrlDomain) {
// Blank config, we use the proxy IP
sb.append(proxyIpAddress);
} else if (consoleProxyUrlDomain.startsWith("*")) {
sb.append(proxyIpAddress.replaceAll("\\.", "-"));
sb.append(consoleProxyUrlDomain.substring(1)); // skip the *
} else {
// Otherwise we assume a valid domain if config not blank
sb.append(consoleProxyUrlDomain);
}
|
Trillian test result (tid-25)
|
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-32 |
|
@blueorangutan test |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests |
|
Trillian test result (tid-32)
|
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
Types of changes