From 5a7875e78a1d78fd1309c6cd9c40c6a740d6a932 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Tue, 9 May 2023 20:06:57 +0200 Subject: [PATCH] [MNG-6829] refactor: Replace any StringUtils#isEmpty(String) and #isNotEmpty(String) (#169) * [MNG-6829] refactor: Replace any StringUtils#isEmpty(String) and #isNotEmpty(String) ### [Replace any StringUtils#isEmpty(String) and #isNotEmpty(String)](https://public.moderne.io/recipes/org.openrewrite.java.migrate.apache.commons.lang.IsNotEmptyToJdk) A continuation of https://issues.apache.org/jira/browse/MNG-6825 and https://issues.apache.org/jira/browse/MNG-6829, where previously a request was made to instead of switching implementation to a different StringUtils, we should instead switch to using JDK internals where we can. This is a first such pull request to gauge interest before I can potentially make 47 more PRs to replace a total of 210 uses of isEmpty / isNotEmpty. Co-authored-by: Moderne * Apply Spotless --------- Co-authored-by: Moderne --- .../java/org/apache/maven/scm/ChangeSet.java | 5 ++-- .../scm/provider/AbstractScmProvider.java | 27 +++++++++---------- .../maven/scm/util/AbstractConsumer.java | 5 ++-- .../maven/scm/client/cli/MavenScmCli.java | 5 ++-- .../maven/scm/plugin/AbstractScmMojo.java | 25 ++++++++--------- .../maven/scm/plugin/BootstrapMojo.java | 4 +-- .../maven/scm/plugin/ChangeLogMojo.java | 24 ++++++++++------- .../scm/provider/git/GitConfigFileReader.java | 4 +-- .../command/diff/GitDiffRawConsumer.java | 3 +-- .../gitexe/command/info/GitInfoConsumer.java | 2 +- .../command/status/GitStatusConsumer.java | 3 +-- .../GitLatestRevisionCommandConsumer.java | 3 +-- .../scm/provider/svn/SvnCommandUtils.java | 4 +-- .../scm/provider/svn/SvnConfigFileReader.java | 3 +-- .../scm/provider/svn/SvnTagBranchUtils.java | 8 +++--- .../command/export/SvnExeExportCommand.java | 2 +- .../svnexe/command/info/SvnInfoCommand.java | 3 +-- 17 files changed, 61 insertions(+), 69 deletions(-) diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeSet.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeSet.java index 5d5639427..16f37473c 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeSet.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ChangeSet.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.util.FilenameUtils; import org.apache.maven.scm.util.ThreadSafeDateFormat; @@ -302,7 +301,7 @@ public void setDate(String date) { */ public void setDate(String date, String userDatePattern) { try { - if (!StringUtils.isEmpty(userDatePattern)) { + if (!(userDatePattern == null || userDatePattern.isEmpty())) { SimpleDateFormat format = new SimpleDateFormat(userDatePattern); this.date = format.parse(date); @@ -310,7 +309,7 @@ public void setDate(String date, String userDatePattern) { this.date = TIMESTAMP_FORMAT_3.parse(date); } } catch (ParseException e) { - if (!StringUtils.isEmpty(userDatePattern)) { + if (!(userDatePattern == null || userDatePattern.isEmpty())) { try { this.date = TIMESTAMP_FORMAT_3.parse(date); } catch (ParseException pe) { diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/AbstractScmProvider.java b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/AbstractScmProvider.java index 86d9bee18..517325c26 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/provider/AbstractScmProvider.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/provider/AbstractScmProvider.java @@ -23,7 +23,6 @@ import java.util.Date; import java.util.List; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.NoSuchCommandScmException; @@ -193,7 +192,7 @@ public BranchScmResult branch(ScmRepository repository, ScmFileSet fileSet, Stri throws ScmException { ScmBranchParameters scmBranchParameters = new ScmBranchParameters(); - if (StringUtils.isNotEmpty(message)) { + if (message != null && !message.isEmpty()) { scmBranchParameters.setMessage(message); } @@ -251,7 +250,7 @@ public ChangeLogScmResult changeLog( throws ScmException { ScmBranch scmBranch = null; - if (StringUtils.isNotEmpty(branch)) { + if (branch != null && !branch.isEmpty()) { scmBranch = new ScmBranch(branch); } return changeLog(repository, fileSet, startDate, endDate, numDays, scmBranch, null); @@ -324,11 +323,11 @@ public ChangeLogScmResult changeLog( ScmVersion startRevision = null; ScmVersion endRevision = null; - if (StringUtils.isNotEmpty(startTag)) { + if (startTag != null && !startTag.isEmpty()) { startRevision = new ScmRevision(startTag); } - if (StringUtils.isNotEmpty(endTag)) { + if (endTag != null && !endTag.isEmpty()) { endRevision = new ScmRevision(endTag); } @@ -385,7 +384,7 @@ public CheckInScmResult checkIn(ScmRepository repository, ScmFileSet fileSet, St throws ScmException { ScmVersion scmVersion = null; - if (StringUtils.isNotEmpty(tag)) { + if (tag != null && !tag.isEmpty()) { scmVersion = new ScmBranch(tag); } @@ -444,7 +443,7 @@ public CheckOutScmResult checkOut(ScmRepository repository, ScmFileSet fileSet, throws ScmException { ScmVersion scmVersion = null; - if (StringUtils.isNotEmpty(tag)) { + if (tag != null && !tag.isEmpty()) { scmVersion = new ScmBranch(tag); } @@ -524,11 +523,11 @@ public DiffScmResult diff(ScmRepository repository, ScmFileSet fileSet, String s ScmVersion startVersion = null; ScmVersion endVersion = null; - if (StringUtils.isNotEmpty(startRevision)) { + if (startRevision != null && !startRevision.isEmpty()) { startVersion = new ScmRevision(startRevision); } - if (StringUtils.isNotEmpty(endRevision)) { + if (endRevision != null && !endRevision.isEmpty()) { endVersion = new ScmRevision(endRevision); } @@ -601,7 +600,7 @@ public ExportScmResult export(ScmRepository repository, ScmFileSet fileSet, Stri throws ScmException { ScmVersion scmVersion = null; - if (StringUtils.isNotEmpty(tag)) { + if (tag != null && !tag.isEmpty()) { scmVersion = new ScmRevision(tag); } @@ -656,7 +655,7 @@ public ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean throws ScmException { ScmVersion scmVersion = null; - if (StringUtils.isNotEmpty(tag)) { + if (tag != null && !tag.isEmpty()) { scmVersion = new ScmRevision(tag); } @@ -804,7 +803,7 @@ public TagScmResult tag(ScmRepository repository, ScmFileSet fileSet, String tag parameters.setString(CommandParameter.TAG_NAME, tagName); - if (StringUtils.isNotEmpty(message)) { + if (message != null && !message.isEmpty()) { parameters.setString(CommandParameter.MESSAGE, message); } @@ -957,7 +956,7 @@ private UpdateScmResult update( throws ScmException { ScmBranch scmBranch = null; - if (StringUtils.isNotEmpty(tag)) { + if (tag != null && !tag.isEmpty()) { scmBranch = new ScmBranch(tag); } @@ -1017,7 +1016,7 @@ public UpdateScmResult update( throws ScmException { ScmBranch scmBranch = null; - if (StringUtils.isNotEmpty(tag)) { + if (tag != null && !tag.isEmpty()) { scmBranch = new ScmBranch(tag); } diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/util/AbstractConsumer.java b/maven-scm-api/src/main/java/org/apache/maven/scm/util/AbstractConsumer.java index d6a27bf2d..37efa7725 100644 --- a/maven-scm-api/src/main/java/org/apache/maven/scm/util/AbstractConsumer.java +++ b/maven-scm-api/src/main/java/org/apache/maven/scm/util/AbstractConsumer.java @@ -24,7 +24,6 @@ import java.util.Date; import java.util.Locale; -import org.apache.commons.lang3.StringUtils; import org.codehaus.plexus.util.cli.StreamConsumer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,7 +62,7 @@ protected Date parseDate(String date, String userPattern, String defaultPattern, String patternUsed = null; Locale localeUsed = null; - if (StringUtils.isNotEmpty(userPattern)) { + if (userPattern != null && !userPattern.isEmpty()) { if (locale != null) { format = new SimpleDateFormat(userPattern, locale); localeUsed = locale; @@ -73,7 +72,7 @@ protected Date parseDate(String date, String userPattern, String defaultPattern, } patternUsed = userPattern; } else { - if (StringUtils.isNotEmpty(defaultPattern)) { + if (defaultPattern != null && !defaultPattern.isEmpty()) { if (locale != null) { format = new SimpleDateFormat(defaultPattern, locale); localeUsed = locale; diff --git a/maven-scm-client/src/main/java/org/apache/maven/scm/client/cli/MavenScmCli.java b/maven-scm-client/src/main/java/org/apache/maven/scm/client/cli/MavenScmCli.java index b3fa4b471..e5a4f5ecf 100644 --- a/maven-scm-client/src/main/java/org/apache/maven/scm/client/cli/MavenScmCli.java +++ b/maven-scm-client/src/main/java/org/apache/maven/scm/client/cli/MavenScmCli.java @@ -21,7 +21,6 @@ import java.io.File; import java.util.List; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -292,7 +291,7 @@ private void showError(ScmResult result) { String providerMessage = result.getProviderMessage(); - if (!StringUtils.isEmpty(providerMessage)) { + if (!(providerMessage == null || providerMessage.isEmpty())) { System.err.println("Error message from the provider: " + providerMessage); } else { System.err.println("The provider didn't give a error message."); @@ -300,7 +299,7 @@ private void showError(ScmResult result) { String output = result.getCommandOutput(); - if (!StringUtils.isEmpty(output)) { + if (!(output == null || output.isEmpty())) { System.err.println("Command output:"); System.err.println(output); diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java index 33706ee8a..2b5234429 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java @@ -218,9 +218,9 @@ protected void setConnectionType(String connectionType) { public String getConnectionUrl() { boolean requireDeveloperConnection = !"connection".equals(connectionType.toLowerCase()); - if (StringUtils.isNotEmpty(connectionUrl) && !requireDeveloperConnection) { + if ((connectionUrl != null && !connectionUrl.isEmpty()) && !requireDeveloperConnection) { return connectionUrl; - } else if (StringUtils.isNotEmpty(developerConnectionUrl)) { + } else if (developerConnectionUrl != null && !developerConnectionUrl.isEmpty()) { return developerConnectionUrl; } if (requireDeveloperConnection) { @@ -272,15 +272,15 @@ public ScmRepository getScmRepository() throws ScmException { providerRepo.setPushChanges(pushChanges); - if (!StringUtils.isEmpty(workItem)) { + if (!(workItem == null || workItem.isEmpty())) { providerRepo.setWorkItem(workItem); } - if (!StringUtils.isEmpty(username)) { + if (!(username == null || username.isEmpty())) { providerRepo.setUser(username); } - if (!StringUtils.isEmpty(password)) { + if (!(password == null || password.isEmpty())) { providerRepo.setPassword(password); } @@ -289,24 +289,25 @@ public ScmRepository getScmRepository() throws ScmException { loadInfosFromSettings(repo); - if (!StringUtils.isEmpty(username)) { + if (!(username == null || username.isEmpty())) { repo.setUser(username); } - if (!StringUtils.isEmpty(password)) { + if (!(password == null || password.isEmpty())) { repo.setPassword(password); } - if (!StringUtils.isEmpty(privateKey)) { + if (!(privateKey == null || privateKey.isEmpty())) { repo.setPrivateKey(privateKey); } - if (!StringUtils.isEmpty(passphrase)) { + if (!(passphrase == null || passphrase.isEmpty())) { repo.setPassphrase(passphrase); } } - if (!StringUtils.isEmpty(tagBase) && repository.getProvider().equals("svn")) { + if (!(tagBase == null || tagBase.isEmpty()) + && repository.getProvider().equals("svn")) { SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) repository.getProviderRepository(); svnRepo.setTagBase(tagBase); @@ -405,11 +406,11 @@ public void setExcludes(String excludes) { } public ScmVersion getScmVersion(String versionType, String version) throws MojoExecutionException { - if (StringUtils.isEmpty(versionType) && StringUtils.isNotEmpty(version)) { + if ((versionType == null || versionType.isEmpty()) && (version != null && !version.isEmpty())) { throw new MojoExecutionException("You must specify the version type."); } - if (StringUtils.isEmpty(version)) { + if (version == null || version.isEmpty()) { return null; } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java index b93302930..c7c60a1fa 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java @@ -159,13 +159,13 @@ private void runGoals(String relativePathProjectDirectory) throws MojoExecutionE protected String determineWorkingDirectoryPath( File checkoutDirectory, String relativePathProjectDirectory, String goalsDirectory) { File projectDirectory; - if (StringUtils.isNotEmpty(relativePathProjectDirectory)) { + if (relativePathProjectDirectory != null && !relativePathProjectDirectory.isEmpty()) { projectDirectory = new File(checkoutDirectory, relativePathProjectDirectory); } else { projectDirectory = checkoutDirectory; } - if (StringUtils.isEmpty(goalsDirectory)) { + if (goalsDirectory == null || goalsDirectory.isEmpty()) { return projectDirectory.getPath(); } diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java index 5cae70602..172ace987 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ChangeLogMojo.java @@ -23,7 +23,6 @@ import java.text.SimpleDateFormat; import java.util.Date; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -143,24 +142,28 @@ public void execute() throws MojoExecutionException { request.setDatePattern(dateFormat); - if (StringUtils.isNotEmpty(startDate)) { + if (startDate != null && !startDate.isEmpty()) { request.setStartDate(parseDate(localFormat, startDate)); } - if (StringUtils.isNotEmpty(endDate)) { + if (endDate != null && !endDate.isEmpty()) { request.setEndDate(parseDate(localFormat, endDate)); } - if (StringUtils.isNotEmpty(startScmVersion)) { + if (startScmVersion != null && !startScmVersion.isEmpty()) { ScmVersion startRev = getScmVersion( - StringUtils.isEmpty(startScmVersionType) ? VERSION_TYPE_REVISION : startScmVersionType, + (startScmVersionType == null || startScmVersionType.isEmpty()) + ? VERSION_TYPE_REVISION + : startScmVersionType, startScmVersion); request.setStartRevision(startRev); } - if (StringUtils.isNotEmpty(endScmVersion)) { + if (endScmVersion != null && !endScmVersion.isEmpty()) { ScmVersion endRev = getScmVersion( - StringUtils.isEmpty(endScmVersionType) ? VERSION_TYPE_REVISION : endScmVersionType, + (endScmVersionType == null || endScmVersionType.isEmpty()) + ? VERSION_TYPE_REVISION + : endScmVersionType, endScmVersion); request.setEndRevision(endRev); } @@ -171,13 +174,14 @@ public void execute() throws MojoExecutionException { request.setNumDays(numDays); } - if (StringUtils.isNotEmpty(scmVersion)) { + if (scmVersion != null && !scmVersion.isEmpty()) { ScmVersion rev = getScmVersion( - StringUtils.isEmpty(scmVersionType) ? VERSION_TYPE_REVISION : scmVersionType, scmVersion); + (scmVersionType == null || scmVersionType.isEmpty()) ? VERSION_TYPE_REVISION : scmVersionType, + scmVersion); request.setRevision(rev); } - if (StringUtils.isNotEmpty(scmBranch)) { + if (scmBranch != null && !scmBranch.isEmpty()) { request.setScmBranch(new ScmBranch(scmBranch)); } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitConfigFileReader.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitConfigFileReader.java index effe9d8c4..90687eada 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitConfigFileReader.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/GitConfigFileReader.java @@ -26,8 +26,6 @@ import java.util.Iterator; import java.util.List; -import org.apache.commons.lang3.StringUtils; - /** * @author Emmanuel Venisse * @@ -110,7 +108,7 @@ private List getConfLines() { new BufferedReader(new FileReader(new File(getConfigDirectory(), "config")))) { String line; while ((line = reader.readLine()) != null) { - if (!line.startsWith("#") && StringUtils.isNotEmpty(line)) { + if (!line.startsWith("#") && (line != null && !line.isEmpty())) { lines.add(line); } } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumer.java index 32d2d736d..3664a3164 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/diff/GitDiffRawConsumer.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.util.AbstractConsumer; @@ -44,7 +43,7 @@ public void consumeLine(String line) { if (logger.isDebugEnabled()) { logger.debug(line); } - if (StringUtils.isEmpty(line)) { + if (line == null || line.isEmpty()) { return; } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoConsumer.java index 3e96b477e..7d8066eff 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoConsumer.java @@ -52,7 +52,7 @@ public void consumeLine(String line) { } if (infoItems.isEmpty()) { - if (!StringUtils.isEmpty(line)) { + if (!(line == null || line.isEmpty())) { InfoItem infoItem = new InfoItem(); infoItem.setRevision(StringUtils.trim(line)); infoItem.setURL(scmFileSet.getBasedir().toPath().toUri().toASCIIString()); diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java index 473db8952..942a017cc 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java @@ -27,7 +27,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmFileStatus; @@ -145,7 +144,7 @@ public void consumeLine(String line) { if (logger.isDebugEnabled()) { logger.debug(line); } - if (StringUtils.isEmpty(line)) { + if (line == null || line.isEmpty()) { return; } diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumer.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumer.java index b9bd4566a..60307d7f1 100644 --- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumer.java +++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/update/GitLatestRevisionCommandConsumer.java @@ -21,7 +21,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.scm.util.AbstractConsumer; /** @@ -42,7 +41,7 @@ public void consumeLine(String line) { if (logger.isDebugEnabled()) { logger.debug("GitLatestRevisionCommandConsumer consumeLine : " + line); } - if (line == null || StringUtils.isEmpty(line)) { + if (line == null || (line == null || line.isEmpty())) { return; } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnCommandUtils.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnCommandUtils.java index 2da1068ff..01725979b 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnCommandUtils.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnCommandUtils.java @@ -18,8 +18,6 @@ */ package org.apache.maven.scm.provider.svn; -import org.apache.commons.lang3.StringUtils; - /** * Command utilities for svn commands. * @@ -44,7 +42,7 @@ private SvnCommandUtils() {} * @throws NullPointerException if url is null */ public static String fixUrl(String url, String username) { - if (!StringUtils.isEmpty(username) && url.startsWith("svn+ssh://")) { + if (!(username == null || username.isEmpty()) && url.startsWith("svn+ssh://")) { // is there a username to override ? If so we cut after int idx = url.indexOf('@'); int cutIdx = idx < 0 ? "svn+ssh://".length() : idx + 1; diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnConfigFileReader.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnConfigFileReader.java index 74bae40ab..e3dd9276f 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnConfigFileReader.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnConfigFileReader.java @@ -26,7 +26,6 @@ import java.util.Iterator; import java.util.List; -import org.apache.commons.lang3.StringUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.Os; @@ -106,7 +105,7 @@ private List getConfLines() { reader = new BufferedReader(new FileReader(new File(getConfigDirectory(), "config"))); String line; while ((line = reader.readLine()) != null) { - if (!line.startsWith("#") && StringUtils.isNotEmpty(line)) { + if (!line.startsWith("#") && (line != null && !line.isEmpty())) { lines.add(line); } } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java index 0c2784a1d..6e2699e40 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/SvnTagBranchUtils.java @@ -49,7 +49,7 @@ private SvnTagBranchUtils() {} static String appendPath(String basePath, String addlPath) { basePath = StringUtils.stripEnd(basePath, "/"); - if (StringUtils.isEmpty(addlPath)) { + if (addlPath == null || addlPath.isEmpty()) { return basePath; } else { return basePath + "/" + StringUtils.stripStart(addlPath, "/"); @@ -180,7 +180,7 @@ public static String resolveUrl(String repositoryUrl, String tagBase, String sub String projectRoot = getProjectRoot(repositoryUrl); branchTagName = StringUtils.strip(branchTagName, "/"); - if (StringUtils.isEmpty(branchTagName)) { + if (branchTagName == null || branchTagName.isEmpty()) { return null; } @@ -198,7 +198,7 @@ public static String resolveUrl(String repositoryUrl, String tagBase, String sub } // User has a tagBase specified so just return the name appended to the tagBase - if (StringUtils.isNotEmpty(tagBase) + if ((tagBase != null && !tagBase.isEmpty()) && !tagBase.equals(resolveTagBase(repositoryUrl)) && !tagBase.equals(resolveBranchBase(repositoryUrl))) { return appendPath(tagBase, branchTagName); @@ -252,7 +252,7 @@ public static boolean isRevisionSpecifier(ScmVersion version) { String versionName = version.getName(); - if (StringUtils.isEmpty(versionName)) { + if (versionName == null || versionName.isEmpty()) { return false; } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExeExportCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExeExportCommand.java index 9ee5c8550..d1fb2f164 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExeExportCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExeExportCommand.java @@ -132,7 +132,7 @@ public static Commandline createCommandLine( cl.createArg().setValue(url + "@"); - if (StringUtils.isNotEmpty(outputSirectory)) { + if (outputSirectory != null && !outputSirectory.isEmpty()) { cl.createArg().setValue(outputSirectory + "@"); } diff --git a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java index 88c36ba61..5609f2d73 100644 --- a/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java +++ b/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java @@ -21,7 +21,6 @@ import java.io.File; import java.util.Iterator; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -96,7 +95,7 @@ protected static Commandline createCommandLine( cl.createArg().setValue("--recursive"); } - if (StringUtils.isNotEmpty(revision)) { + if (revision != null && !revision.isEmpty()) { cl.createArg().setValue("-r"); cl.createArg().setValue(revision);