Avoid URICheckEncodingMonitor empty value NPE

https://community.jenkins.io/t/reverse-proxy-test-does-not-handle-url-correctly/1294/9
reports that an empty value returned to the URI encoding check monitor
will report a null pointer exception.  An empty value is unexpected in
that context, but it is easy to check for null and avoid the null
pointer exception.

No Jira ticket was opened for the issue.  I can open a Jira ticket if
that is required.
This commit is contained in:
Mark Waite committed 2022-12-23 10:10:28 -07:00
1 parent d1c0bbc99c
commit fd2f7e817b
1 file changed
+1 -1
@@ -43,7 +43,7 @@ public class URICheckEncodingMonitor extends AdministrativeMonitor {
if (!expected.equals(value)) {
String expectedHex = Util.toHexString(expected.getBytes(StandardCharsets.UTF_8));
String valueHex = Util.toHexString(value.getBytes(StandardCharsets.UTF_8));
String valueHex = value != null ? Util.toHexString(value.getBytes(StandardCharsets.UTF_8)) : "<empty string>";
LOGGER.log(Level.CONFIG, "Expected to receive: " + expected + " (" + expectedHex + ") but got: " + value + " (" + valueHex + ")");
return FormValidation.warningWithMarkup(hudson.model.Messages.Hudson_NotUsesUTF8ToDecodeURL());
}