Skip to content

Commit

Permalink
[JENKINS-49083] - make URL Validator a static field.
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-nenashev committed Jan 23, 2018
1 parent dd40d9a commit ac82aab
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -45,7 +45,7 @@ public final class GlobalRabbitmqConfiguration extends GlobalConfiguration {
@SuppressWarnings("unused")
private static final Logger LOGGER = LoggerFactory.getLogger(GlobalRabbitmqConfiguration.class);
private static final String[] AMQP_SCHEMES = { "amqp", "amqps" };
private final UrlValidator urlValidator = new UrlValidator(AMQP_SCHEMES, UrlValidator.ALLOW_LOCAL_URLS);
private static final UrlValidator URL_VALIDATOR = new UrlValidator(AMQP_SCHEMES, UrlValidator.ALLOW_LOCAL_URLS);

private boolean enableConsumer;
private String serviceUri;
Expand Down Expand Up @@ -110,7 +110,7 @@ public boolean configure(StaplerRequest req, JSONObject json) throws hudson.mode
timer.setRecurrencePeriod(watchdogPeriod);
}

if (urlValidator.isValid(serviceUri)) {
if (URL_VALIDATOR.isValid(serviceUri)) {
save();
return true;
}
Expand Down Expand Up @@ -251,7 +251,7 @@ public FormValidation doCheckServiceUri(@QueryParameter String value) {
return FormValidation.ok();
}

if (urlValidator.isValid(val)) {
if (URL_VALIDATOR.isValid(val)) {
return FormValidation.ok();
} else {
return FormValidation.error(Messages.InvalidURI());
Expand All @@ -275,7 +275,7 @@ public FormValidation doTestConnection(@QueryParameter("serviceUri") String serv
@QueryParameter("userName") String userName,
@QueryParameter("userPassword") Secret userPassword) throws ServletException {
String uri = StringUtils.strip(StringUtils.stripToNull(serviceUri), "/");
if (uri != null && urlValidator.isValid(uri)) {
if (uri != null && URL_VALIDATOR.isValid(uri)) {
try {
ConnectionFactory factory = new ConnectionFactory();
factory.setUri(uri);
Expand Down

0 comments on commit ac82aab

Please sign in to comment.