Skip to content
Permalink
Browse files

[JENKINS-49083] - make URL Validator a static field.

  • Loading branch information...
oleg-nenashev committed Jan 23, 2018
1 parent dd40d9a commit ac82aab58f44e9f90f872249bdde2c9468dcfcfe
@@ -45,7 +45,7 @@
@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;
@@ -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;
}
@@ -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());
@@ -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);

0 comments on commit ac82aab

Please sign in to comment.
You can’t perform that action at this time.