Source:
<code>public boolean publish(String message, String color) { boolean result = true; for (String roomId : roomIds) { String url = "https://" + teamDomain + "." + host + "/services/hooks/jenkins-ci?token=" + token; <START> if (StringUtils.isEmpty(baseUrl)) { <END> url = baseUrl + token; } logger.info("Posting: to " + roomId + " on " + teamDomain + " using " + url +": " + message + " " + color); HttpClient client = getHttpClient(); PostMethod post = new PostMethod(url); JSONObject json = new JSONObject(); try { JSONObject field = new JSONObject(); field.put("short", false); field.put("value", message); JSONArray fields = new JSONArray(); fields.put(field); JSONObject attachment = new JSONObject(); attachment.put("fallback", message); attachment.put("color", color); attachment.put("fields", fields); JSONArray mrkdwn = new JSONArray(); mrkdwn.put("pretext"); mrkdwn.put("text"); mrkdwn.put("fields"); attachment.put("mrkdwn_in", mrkdwn); JSONArray attachments = new JSONArray(); attachments.put(attachment); json.put("channel", roomId); json.put("attachments", attachments); post.addParameter("payload", json.toString()); post.getParams().setContentCharset("UTF-8"); int responseCode = client.executeMethod(post); String response = post.getResponseBodyAsString(); if(responseCode != HttpStatus.SC_OK) { logger.log(Level.WARNING, "Slack post may have failed. Response: " + response); result = false; } else { logger.info("Posting succeeded"); } } catch (Exception e) { logger.log(Level.WARNING, "Error posting to Slack", e); result = false; } finally { post.releaseConnection(); } } return result; }</code><technical_language>point of testing StringUtils.isEmpty(baseUrl) if evaluates true baseUrl? checking for empty? e.g. groovy if (!StringUtils.isEmpty(baseUrl)) { //stuff }</technical_language>

Target:
public boolean publish(String message, String color) { boolean result = true; for (String roomId : roomIds) { String url = "https://" + teamDomain + "." + host + "/services/hooks/jenkins-ci?token=" + token; if (!StringUtils.isEmpty(baseUrl)) { url = baseUrl + token; } logger.info("Posting: to " + roomId + " on " + teamDomain + " using " + url +": " + message + " " + color); HttpClient client = getHttpClient(); PostMethod post = new PostMethod(url); JSONObject json = new JSONObject(); try { JSONObject field = new JSONObject(); field.put("short", false); field.put("value", message); JSONArray fields = new JSONArray(); fields.put(field); JSONObject attachment = new JSONObject(); attachment.put("fallback", message); attachment.put("color", color); attachment.put("fields", fields); JSONArray mrkdwn = new JSONArray(); mrkdwn.put("pretext"); mrkdwn.put("text"); mrkdwn.put("fields"); attachment.put("mrkdwn_in", mrkdwn); JSONArray attachments = new JSONArray(); attachments.put(attachment); json.put("channel", roomId); json.put("attachments", attachments); post.addParameter("payload", json.toString()); post.getParams().setContentCharset("UTF-8"); int responseCode = client.executeMethod(post); String response = post.getResponseBodyAsString(); if(responseCode != HttpStatus.SC_OK) { logger.log(Level.WARNING, "Slack post may have failed. Response: " + response); result = false; } else { logger.info("Posting succeeded"); } } catch (Exception e) { logger.log(Level.WARNING, "Error posting to Slack", e); result = false; } finally { post.releaseConnection(); } } return result; }