From: Svjatoslav Agejenko Date: Fri, 2 Oct 2020 14:45:00 +0000 (+0300) Subject: Properly handle zero length strings when trimming X-Git-Tag: svjatoslavcommons-1.8~4 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=b36e41f7fa4cc97248027402b60ba11a0bfdb64c;p=svjatoslav_commons.git Properly handle zero length strings when trimming --- diff --git a/src/main/java/eu/svjatoslav/commons/string/String2.java b/src/main/java/eu/svjatoslav/commons/string/String2.java index 8d7273d..c18633a 100755 --- a/src/main/java/eu/svjatoslav/commons/string/String2.java +++ b/src/main/java/eu/svjatoslav/commons/string/String2.java @@ -86,7 +86,7 @@ public class String2 { if (actualCutAmount > getLength()) actualCutAmount = getLength(); - chars.subList(0, actualCutAmount).clear(); + if (actualCutAmount > 0) chars.subList(0, actualCutAmount).clear(); return this; }