@@ -3,7 +3,7 @@
-------------------------------------------------------------------------------------------------------------
-## 5.3.9 (2020-06-17)
+## 5.3.9 (2020-06-23)
### 新特性
* 【core 】 DateUtil增加formatChineseDate(pr#932@Github)
@@ -11,6 +11,7 @@
### Bug修复
* 【core 】 修复NumberUtil.partValue有余数问题(issue#I1KX66@Gitee)
* 【core 】 修复BeanUtil.isEmpty不能忽略static字段问题(issue#I1KZI6@Gitee)
+* 【core 】 修复StrUtil.brief长度问题(pr#930@Github)
## 5.3.8 (2020-06-16)
@@ -3312,11 +3312,11 @@ public class StrUtil {
if (null == str) {
return null;
}
- if ((str.length() + 3) <= maxLength) {
+ if (str.length() <= maxLength) {
return str.toString();
int w = maxLength / 2;
- int l = str.length();
+ int l = str.length() + 3;
final String str2 = str.toString();
return format("{}...{}", str2.substring(0, maxLength - w), str2.substring(l - w));
@@ -448,5 +448,12 @@ public class StrUtilTest {
String[] results2 = StrUtil.subBetweenAll(src2,"/*","*/");
Assert.assertEquals(0, results2.length);
-
+
+ @Test
+ public void briefTest(){
+ String str = RandomUtil.randomString(1000);
+ int maxLength = RandomUtil.randomInt(1000);
+ String brief = StrUtil.brief(str, maxLength);
+ Assert.assertEquals(brief.length(), maxLength);
+ }