Skip to content

Commit

Permalink
Prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed May 27, 2022
2 parents a0c65de + 493da88 commit acfb7bc
Show file tree
Hide file tree
Showing 53 changed files with 298 additions and 90 deletions.
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@

-------------------------------------------------------------------------------------------------------------

# 5.8.2 (2022-05-27)

### 🐣新特性
* 【core 】 BeanUtil拷贝对象增加空检查(issue#I58CJ3@Gitee)
* 【db 】 Column#size改为long
* 【core 】 ClassUtil增加isInterface等方法(pr#623@Gitee)
* 【socket 】 增加ChannelUtil

### 🐞Bug修复
* 【extra 】 修复SshjSftp初始化未能代入端口配置问题(issue#2333@Github)
* 【core 】 修复Convert.numberToSimple转换问题(issue#2334@Github)
* 【core 】 修复TemporalAccessorConverter导致的转换问题(issue#2341@Github)
* 【core 】 修复NumberUtil除法空指针问题(issue#I58XKE@Gitee)
* 【core 】 修复CAR_VIN正则(pr#624@Gitee)
* 【db 】 修复count查询别名问题(issue#I590YB@Gitee)
* 【json 】 修复json中byte[]无法转换问题(issue#I59LW4@Gitee)
* 【core 】 修复NumberUtil.isXXX未判空问题(issue#2350@Github)
* 【core 】 修复Singleton中ConcurrentHashMap在JDK8下的bug引起的可能的死循环问题(issue#2349@Github)

-------------------------------------------------------------------------------------------------------------

# 5.8.1 (2022-05-16)

### 🐣新特性
Expand All @@ -13,7 +34,7 @@
* 【core 】 ByteUtil新增bytesToShort重载(issue#I57FA7@Gitee)
* 【core 】 ReflectUtil.invoke方法抛出运行时异常增加InvocationTargetRuntimeException(issue#I57GI2@Gitee)
* 【core 】 NumberUtil.parseNumber支持16进制(issue#2328@Github)
*

### 🐞Bug修复
* 【core 】 MapUtil.map对null友好,且修复了测试用例中分组问题(pr#614@Gitee)
* 【core 】 修复BeanUtil.beanToMap中properties为null的空指针问题(issue#2303@Github)
Expand Down
6 changes: 3 additions & 3 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,18 @@ We provide the T-Shirt and Sweater with Hutool Logo, please visit the shop:
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
</dependency>
```

### 🍐Gradle
```
implementation 'cn.hutool:hutool-all:5.8.1'
implementation 'cn.hutool:hutool-all:5.8.2'
```

## 📥Download

- [Maven Repo](https://repo1.maven.org/maven2/cn/hutool/hutool-all/5.8.1/)
- [Maven Repo](https://repo1.maven.org/maven2/cn/hutool/hutool-all/5.8.2/)

> 🔔️note:
> Hutool 5.x supports JDK8+ and is not tested on Android platforms, and cannot guarantee that all tool classes or tool methods are available.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,20 @@ Hutool的存在就是为了减少代码搜索成本,避免网络上参差不
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
</dependency>
```

### 🍐Gradle
```
implementation 'cn.hutool:hutool-all:5.8.1'
implementation 'cn.hutool:hutool-all:5.8.2'
```

### 📥下载jar

点击以下链接,下载`hutool-all-X.X.X.jar`即可:

- [Maven中央库](https://repo1.maven.org/maven2/cn/hutool/hutool-all/5.8.1/)
- [Maven中央库](https://repo1.maven.org/maven2/cn/hutool/hutool-all/5.8.2/)

> 🔔️注意
> Hutool 5.x支持JDK8+,对Android平台没有测试,不能保证所有工具类或工具方法可用。
Expand Down
2 changes: 1 addition & 1 deletion bin/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.8.1
5.8.2
2 changes: 1 addition & 1 deletion docs/js/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
var version = '5.8.1'
var version = '5.8.2'
2 changes: 1 addition & 1 deletion hutool-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
</parent>

<artifactId>hutool-all</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-aop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
</parent>

<artifactId>hutool-aop</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-bloomFilter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
</parent>

<artifactId>hutool-bloomFilter</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
</parent>

<artifactId>hutool-bom</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
</parent>

<artifactId>hutool-cache</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-captcha/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
</parent>

<artifactId>hutool-captcha</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hutool-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>cn.hutool</groupId>
<artifactId>hutool-parent</artifactId>
<version>5.8.1</version>
<version>5.8.2</version>
</parent>

<artifactId>hutool-core</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions hutool-core/src/main/java/cn/hutool/core/bean/BeanUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ public static Map<String, Object> beanToMap(Object bean, Map<String, Object> tar
* @return 目标对象
*/
public static <T> T copyProperties(Object source, Class<T> tClass, String... ignoreProperties) {
if(null == source){
return null;
}
T target = ReflectUtil.newInstanceIfPossible(tClass);
copyProperties(source, target, CopyOptions.create().setIgnoreProperties(ignoreProperties));
return target;
Expand Down Expand Up @@ -765,6 +768,9 @@ public static void copyProperties(Object source, Object target, boolean ignoreCa
* @param copyOptions 拷贝选项,见 {@link CopyOptions}
*/
public static void copyProperties(Object source, Object target, CopyOptions copyOptions) {
if(null == source){
return;
}
BeanCopier.create(source, target, ObjectUtil.defaultIfNull(copyOptions, CopyOptions::create)).copy();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.hutool.core.bean.copier;

import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.copier.Copier;

import java.io.Serializable;
Expand Down Expand Up @@ -62,6 +63,8 @@ public static <T> BeanCopier<T> create(Object source, T target, Type destType, C
* @param copyOptions 拷贝属性选项
*/
public BeanCopier(Object source, T target, Type targetType, CopyOptions copyOptions) {
Assert.notNull(source, "Source bean must be not null!");
Assert.notNull(target, "Target bean must be not null!");
Copier<T> copier;
if (source instanceof Map) {
if (target instanceof Map) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static String formatSimple(long value, boolean isTwo) {
int index = -1;
double res = value;
while (res > 10 && (false == isTwo || index < 1)) {
if (res > 1000) {
if (res >= 1000) {
res = res / 1000;
index++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ public void setFormat(String format) {
this.format = format;
}

@SuppressWarnings("unchecked")
@Override
public Class<TemporalAccessor> getTargetType() {
return (Class<TemporalAccessor>) this.targetType;
}

@Override
protected TemporalAccessor convertInternal(Object value) {
if (value instanceof Long) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public interface RegexPool {
* 十七位码、车架号
* 车辆的唯一标示
*/
String CAR_VIN = "^[A-Za-z0-9]{17}$";
String CAR_VIN = "^[A-HJ-NPR-Z0-9]{8}[0-9X][A-HJ-NPR-Z0-9]{2}\\d{6}$";
/**
* 驾驶证 别名:驾驶证档案编号、行驶证编号
* eg:430101758218
Expand Down
10 changes: 9 additions & 1 deletion hutool-core/src/main/java/cn/hutool/core/lang/Singleton.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ public static <T> T get(Class<T> clazz, Object... params) {
*/
@SuppressWarnings("unchecked")
public static <T> T get(String key, Func0<T> supplier) {
return (T) POOL.computeIfAbsent(key, (k)-> supplier.callWithRuntimeException());
//return (T) POOL.computeIfAbsent(key, (k)-> supplier.callWithRuntimeException());
// issues#2349
// ConcurrentHashMap.computeIfAbsent在某些情况下会导致死循环问题,此处采用Dubbo的解决方案
Object value = POOL.get(key);
if(null == value){
POOL.putIfAbsent(key, supplier.callWithRuntimeException());
value = POOL.get(key);
}
return (T) value;
}

/**
Expand Down
22 changes: 22 additions & 0 deletions hutool-core/src/main/java/cn/hutool/core/util/ClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1110,4 +1110,26 @@ public static String getLocationPath(Class<?> clazz) {
}
return location.getPath();
}

/**
* 是否为抽象类或接口
*
* @param clazz 类
* @return 是否为抽象类或接口
* @since 5.8.2
*/
public static boolean isAbstractOrInterface(Class<?> clazz) {
return isAbstract(clazz) || isInterface(clazz);
}

/**
* 是否为接口
*
* @param clazz 类
* @return 是否为接口
* @since 5.8.2
*/
public static boolean isInterface(Class<?> clazz) {
return clazz.isInterface();
}
}
34 changes: 20 additions & 14 deletions hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ public static BigDecimal div(Number v1, Number v2, int scale, RoundingMode round
if (v1 instanceof BigDecimal && v2 instanceof BigDecimal) {
return div((BigDecimal) v1, (BigDecimal) v2, scale, roundingMode);
}
return div(v1.toString(), v2.toString(), scale, roundingMode);
return div(StrUtil.toStringOrNull(v1), StrUtil.toStringOrNull(v2), scale, roundingMode);
}

/**
Expand Down Expand Up @@ -1238,10 +1238,12 @@ public static boolean isNumber(CharSequence str) {
* @return 是否为整数
*/
public static boolean isInteger(String s) {
try {
Integer.parseInt(s);
} catch (NumberFormatException e) {
return false;
if(StrUtil.isNotBlank(s)) {
try {
Integer.parseInt(s);
} catch (NumberFormatException e) {
return false;
}
}
return true;
}
Expand All @@ -1255,10 +1257,12 @@ public static boolean isInteger(String s) {
* @since 4.0.0
*/
public static boolean isLong(String s) {
try {
Long.parseLong(s);
} catch (NumberFormatException e) {
return false;
if(StrUtil.isNotBlank(s)) {
try {
Long.parseLong(s);
} catch (NumberFormatException e) {
return false;
}
}
return true;
}
Expand All @@ -1270,11 +1274,13 @@ public static boolean isLong(String s) {
* @return 是否为{@link Double}类型
*/
public static boolean isDouble(String s) {
try {
Double.parseDouble(s);
return s.contains(".");
} catch (NumberFormatException ignore) {
// ignore
if(StrUtil.isNotBlank(s)) {
try {
Double.parseDouble(s);
return s.contains(".");
} catch (NumberFormatException ignore) {
// ignore
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,11 @@ public void copyBeanTest() {
Assert.assertNull(newFood.getCode());
}

@Test
public void copyNullTest() {
Assert.assertNull(BeanUtil.copyProperties(null, Food.class));
}

@Test
public void copyBeanPropertiesFilterTest() {
Food info = new Food();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
Expand Down Expand Up @@ -383,4 +385,11 @@ public void doubleToFloatTest(){
float b = Convert.toFloat(a);
Assert.assertEquals(a, b, 5);
}

@Test
public void localDateTimeToLocalDateTest(){
final LocalDateTime localDateTime = LocalDateTime.now();
final LocalDate convert = Convert.convert(LocalDate.class, localDateTime);
Assert.assertEquals(localDateTime.toLocalDate(), convert);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ public void formatSimpleTest() {
String format5 = NumberWordFormatter.formatSimple(438);
Assert.assertEquals("438", format5);
}

@Test
public void formatSimpleTest2(){
final String s = NumberWordFormatter.formatSimple(1000);
Assert.assertEquals("1k", s);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public void isBetweenTest() {
public void isCarVinTest(){
Assert.assertTrue(Validator.isCarVin("LSJA24U62JG269225"));
Assert.assertTrue(Validator.isCarVin("LDC613P23A1305189"));
Assert.assertFalse(Validator.isCarVin("LOC613P23A1305189"));
}

@Test
Expand Down
10 changes: 10 additions & 0 deletions hutool-core/src/test/java/cn/hutool/core/util/NumberUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,16 @@ public void isOddOrEvenTest(){
Assert.assertFalse(NumberUtil.isEven(a[4]));
}

@Test
public void divIntegerTest(){
Assert.assertEquals(1001013, NumberUtil.div(100101300, (Number) 100).intValue());
}

@Test
public void isDoubleTest(){
Assert.assertFalse(NumberUtil.isDouble(null));
Assert.assertFalse(NumberUtil.isDouble(""));
Assert.assertFalse(NumberUtil.isDouble(" "));
}

}
Loading

0 comments on commit acfb7bc

Please sign in to comment.