diff --git a/src/main/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfig.java b/src/main/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfig.java index 29b817a..9cc613f 100644 --- a/src/main/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfig.java +++ b/src/main/java/com/dabsquared/gitlabjenkins/connection/GitLabConnectionConfig.java @@ -18,6 +18,7 @@ import hudson.util.ListBoxModel; import jenkins.model.GlobalConfiguration; import jenkins.model.Jenkins; import net.sf.json.JSONObject; +import org.eclipse.jgit.util.StringUtils; import org.jenkinsci.plugins.plaincredentials.StringCredentials; import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; @@ -70,7 +71,7 @@ public class GitLabConnectionConfig extends GlobalConfiguration { } public FormValidation doCheckName(@QueryParameter String id, @QueryParameter String value) { - if (value == null || value.isEmpty()) { + if (StringUtils.isEmptyOrNull(value)) { return FormValidation.error(Messages.name_required()); } else if (connectionMap.containsKey(value) && !connectionMap.get(value).toString().equals(id)) { return FormValidation.error(Messages.name_exists(value)); @@ -80,7 +81,7 @@ public class GitLabConnectionConfig extends GlobalConfiguration { } public FormValidation doCheckUrl(@QueryParameter String value) { - if (value == null || value.isEmpty()) { + if (StringUtils.isEmptyOrNull(value)) { return FormValidation.error(Messages.url_required()); } else { return FormValidation.ok(); @@ -89,7 +90,7 @@ public class GitLabConnectionConfig extends GlobalConfiguration { // TODO check why this gets called twice on page load once with the correct id and once with an empty string public FormValidation doCheckApiTokenId(@QueryParameter String value) { - if (value == null || value.isEmpty()) { + if (StringUtils.isEmptyOrNull(value)) { return FormValidation.error(Messages.apiToken_required()); } else { return FormValidation.ok();