commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [commons-lang] garydgregory commented on a change in pull request #477: Lang 1463: StringUtils abbreviate returns String of length greater than maxWidth
Date Mon, 04 Nov 2019 15:49:43 GMT
garydgregory commented on a change in pull request #477: Lang 1463: StringUtils abbreviate
returns String of length greater than maxWidth
URL: https://github.com/apache/commons-lang/pull/477#discussion_r342121655
 
 

 ##########
 File path: src/main/java/org/apache/commons/lang3/StringUtils.java
 ##########
 @@ -332,10 +331,13 @@ public static String abbreviate(final String str, final String abbrevMarker,
fin
      * @since 3.6
      */
     public static String abbreviate(final String str, final String abbrevMarker, int offset,
final int maxWidth) {
-        if (isEmpty(str) || isEmpty(abbrevMarker)) {
+        if (isEmpty(str) && isEmpty(abbrevMarker)) {
+            return str;
+        } else if (isNotEmpty(str) && "".equals(abbrevMarker) && maxWidth>0)
{
 
 Review comment:
   A "magic" string or number is a value that is hard-coded, as opposed to reusing a constant,
in this case, `EMPTY` instead of `""`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message