Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: chinabugotech/hutool
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5.8.31
Choose a base ref
...
head repository: chinabugotech/hutool
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5.8.32
Choose a head ref
  • 18 commits
  • 51 files changed
  • 1 contributor

Commits on Aug 12, 2024

  1. prepare 5.8.32

    looly committed Aug 12, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    60709f8 View commit details
  2. prepare 5.8.32

    looly committed Aug 12, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    67b8bc1 View commit details

Commits on Aug 13, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1cd3f63 View commit details

Commits on Aug 15, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    050c379 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9097e71 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d47e87b View commit details
  4. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d84d033 View commit details

Commits on Aug 19, 2024

  1. add test

    looly committed Aug 19, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a157943 View commit details

Commits on Aug 21, 2024

  1. update dependency

    looly committed Aug 21, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f81dd24 View commit details
  2. add test

    looly committed Aug 21, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e1aa3f6 View commit details

Commits on Aug 22, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9be0fef View commit details

Commits on Aug 24, 2024

  1. add test

    looly committed Aug 24, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    227a6ef View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    63b2f7c View commit details

Commits on Aug 29, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c459a0f View commit details

Commits on Aug 30, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    baac5d0 View commit details
  2. Copy the full SHA
    c3b576f View commit details
  3. Copy the full SHA
    9262ace View commit details
  4. 🍼Release 5.8.32

    looly committed Aug 30, 2024
    Copy the full SHA
    467d67e View commit details
Showing with 379 additions and 125 deletions.
  1. +15 −0 CHANGELOG.md
  2. +3 −3 README-EN.md
  3. +3 −3 README.md
  4. +1 −1 bin/version.txt
  5. +1 −1 docs/js/version.js
  6. +1 −1 hutool-all/pom.xml
  7. +1 −1 hutool-aop/pom.xml
  8. +1 −1 hutool-bloomFilter/pom.xml
  9. +1 −1 hutool-bom/pom.xml
  10. +1 −1 hutool-cache/pom.xml
  11. +1 −1 hutool-captcha/pom.xml
  12. +1 −1 hutool-core/pom.xml
  13. +3 −1 hutool-core/src/main/java/cn/hutool/core/bean/copier/BeanToMapCopier.java
  14. +1 −1 hutool-core/src/main/java/cn/hutool/core/bean/copier/MapToBeanCopier.java
  15. +8 −5 hutool-core/src/main/java/cn/hutool/core/bean/copier/MapToMapCopier.java
  16. +2 −0 hutool-core/src/main/java/cn/hutool/core/bean/copier/ValueProviderToBeanCopier.java
  17. +2 −1 hutool-core/src/main/java/cn/hutool/core/compress/ZipWriter.java
  18. +13 −2 hutool-core/src/main/java/cn/hutool/core/convert/NumberWithFormat.java
  19. +18 −6 hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java
  20. +6 −3 hutool-core/src/main/java/cn/hutool/core/lang/tree/Tree.java
  21. +41 −0 hutool-core/src/test/java/cn/hutool/core/bean/Issue3702Test.java
  22. +14 −0 hutool-core/src/test/java/cn/hutool/core/convert/IssueIALV38Test.java
  23. +14 −0 hutool-core/src/test/java/cn/hutool/core/io/FileUtilTest.java
  24. +26 −0 hutool-core/src/test/java/cn/hutool/core/text/csv/Issue3705Test.java
  25. +1 −0 hutool-core/src/test/resources/test_lines_cr.csv
  26. +7 −0 hutool-core/src/test/resources/test_lines_crlf.csv
  27. +1 −1 hutool-cron/pom.xml
  28. +1 −1 hutool-crypto/pom.xml
  29. +31 −6 hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/AsymmetricCrypto.java
  30. +42 −31 hutool-crypto/src/main/java/cn/hutool/crypto/asymmetric/Sign.java
  31. +23 −13 hutool-crypto/src/main/java/cn/hutool/crypto/symmetric/SymmetricCrypto.java
  32. +1 −1 hutool-db/pom.xml
  33. +1 −1 hutool-dfa/pom.xml
  34. +2 −2 hutool-extra/pom.xml
  35. +1 −1 hutool-http/pom.xml
  36. +28 −4 hutool-http/src/main/java/cn/hutool/http/HttpResponse.java
  37. +1 −1 hutool-json/pom.xml
  38. +3 −10 hutool-json/src/main/java/cn/hutool/json/JSONUtil.java
  39. +2 −2 hutool-json/src/main/java/cn/hutool/json/serialize/GlobalSerializeMapping.java
  40. +7 −8 hutool-json/src/main/java/cn/hutool/json/serialize/JSONWriter.java
  41. +19 −0 hutool-json/src/test/java/cn/hutool/json/IssueIALQ0NTest.java
  42. +1 −1 hutool-jwt/pom.xml
  43. +2 −1 hutool-jwt/src/test/java/cn/hutool/jwt/IssueI6IS5BTest.java
  44. +1 −1 hutool-log/pom.xml
  45. +1 −1 hutool-poi/pom.xml
  46. +20 −0 hutool-poi/src/test/java/cn/hutool/poi/excel/Issue3698Test.java
  47. +1 −1 hutool-script/pom.xml
  48. +1 −1 hutool-setting/pom.xml
  49. +1 −1 hutool-socket/pom.xml
  50. +1 −1 hutool-system/pom.xml
  51. +1 −1 pom.xml
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@

# 🚀Changelog

-------------------------------------------------------------------------------------------------------------
# 5.8.32(2024-08-30)

### 🐣新特性
* 【core 】 FileUtil.getTotalLines()支持CR换行符(issue#IAMZYR@Gitee)
* 【json 】 GlobalSerializeMapping增加null检查(issue#IANH1Y@Gitee)

### 🐞Bug修复
* 【http 】 修复getFileNameFromDisposition不符合规范问题(issue#IAKBPD@Gitee)
* 【crypto 】 修复SymmetricCrypto.setParams和setRandom没有加锁问题(issue#IAJIY3@Gitee)
* 【crypto 】 修复ZipUtil压缩成流的方法检查文件时报错问题(issue#3697@Github)
* 【core 】 修复CopyOptions.setFieldValueEditor后生成null值setIgnoreNullValue无效问题(issue#3702@Github)
* 【json 】 修复JSONConfig.setDateFormat设置后setWriteLongAsString失效问题(issue#IALQ0N@Gitee)
* 【core 】 修复Tree.cloneTree的Parent节点引用错误问题(issue#IANJTC@Gitee)

-------------------------------------------------------------------------------------------------------------
# 5.8.31(2024-08-12)

6 changes: 3 additions & 3 deletions README-EN.md
Original file line number Diff line number Diff line change
@@ -150,18 +150,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.31</version>
<version>5.8.32</version>
</dependency>
```

### 🍐Gradle
```
implementation 'cn.hutool:hutool-all:5.8.31'
implementation 'cn.hutool:hutool-all:5.8.32'
```

## 📥Download

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

> 🔔️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.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -143,20 +143,20 @@ Hutool = Hu + tool,是原公司项目底层代码剥离后的开源库,“Hu
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.31</version>
<version>5.8.32</version>
</dependency>
```

### 🍐Gradle
```
implementation 'cn.hutool:hutool-all:5.8.31'
implementation 'cn.hutool:hutool-all:5.8.32'
```

### 📥下载jar

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

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

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

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

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

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

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

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

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

<artifactId>hutool-core</artifactId>
Original file line number Diff line number Diff line change
@@ -73,9 +73,11 @@ public Map copy() {
if(null != typeArguments && typeArguments.length > 1){
//sValue = Convert.convertWithCheck(typeArguments[1], sValue, null, this.copyOptions.ignoreError);
sValue = this.copyOptions.convertField(typeArguments[1], sValue);
sValue = copyOptions.editFieldValue(sFieldName, sValue);
}

// 自定义值
sValue = copyOptions.editFieldValue(sFieldName, sValue);

// 目标赋值
if(null != sValue || false == copyOptions.ignoreNullValue){
//noinspection unchecked
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
import cn.hutool.core.lang.Assert;
import cn.hutool.core.map.CaseInsensitiveMap;
import cn.hutool.core.map.MapWrapper;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.TypeUtil;

import java.lang.reflect.Type;
@@ -89,6 +88,7 @@ public T copy() {
final Type fieldType = TypeUtil.getActualType(this.targetType, tDesc.getFieldType());
//Object newValue = Convert.convertWithCheck(fieldType, sValue, null, this.copyOptions.ignoreError);
Object newValue = this.copyOptions.convertField(fieldType, sValue);
// 自定义值
newValue = copyOptions.editFieldValue(sKeyStr, newValue);

// 目标赋值
Original file line number Diff line number Diff line change
@@ -37,10 +37,6 @@ public Map copy() {
if (null == sKey) {
return;
}
// 忽略空值
if (true == copyOptions.ignoreNullValue && sValue == null) {
return;
}

if(sKey instanceof String){
sKey = copyOptions.editFieldName((String) sKey);
@@ -66,7 +62,14 @@ public Map copy() {
if (null != typeArguments) {
//sValue = Convert.convertWithCheck(typeArguments[1], sValue, null, this.copyOptions.ignoreError);
sValue = this.copyOptions.convertField(typeArguments[1], sValue);
sValue = copyOptions.editFieldValue(sKey.toString(), sValue);
}

// 自定义值
sValue = copyOptions.editFieldValue(sKey.toString(), sValue);

// 忽略空值
if (true == copyOptions.ignoreNullValue && sValue == null) {
return;
}

// 目标赋值
Original file line number Diff line number Diff line change
@@ -79,6 +79,8 @@ public T copy() {
if (false == copyOptions.testPropertyFilter(tDesc.getField(), sValue)) {
return;
}

// 自定义值
sValue = copyOptions.editFieldValue(tFieldName, sValue);

// 目标赋值
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
* @author looly
* @since 5.7.8
*/
@SuppressWarnings("resource")
public class ZipWriter implements Closeable {

/**
@@ -257,7 +258,7 @@ private ZipWriter _add(File file, String srcRootDir, FileFilter filter) throws I
}
} else {
// issue#IAGYDG 检查加入的文件是否为压缩结果文件本身,避免死循环
if (FileUtil.equals(file, zipFile)) {
if (null != this.zipFile && FileUtil.equals(file, zipFile)) {
return this;
}

Original file line number Diff line number Diff line change
@@ -13,14 +13,15 @@
* @author looly
* @since 5.8.13
*/
public class NumberWithFormat extends Number implements TypeConverter{
public class NumberWithFormat extends Number implements TypeConverter {
private static final long serialVersionUID = 1L;

private final Number number;
private final String format;

/**
* 构造
*
* @param number 数字
* @param format 格式
*/
@@ -40,7 +41,7 @@ public Object convert(Type targetType, Object value) {
return new DateConverter((Class<? extends Date>) clazz, format).convert(this.number, null);
} else if (TemporalAccessor.class.isAssignableFrom(clazz)) {
return new TemporalAccessorConverter(clazz, format).convert(this.number, null);
} else if(String.class == clazz){
} else if (String.class == clazz) {
return toString();
}

@@ -51,6 +52,16 @@ public Object convert(Type targetType, Object value) {
return Convert.convertWithCheck(targetType, this.number, null, false);
}

/**
* 获取原始Number
*
* @return 原始Number
* @since 5.8.32
*/
public Object getNumber() {
return this.number;
}

@Override
public int intValue() {
return this.number.intValue();
24 changes: 18 additions & 6 deletions hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java
Original file line number Diff line number Diff line change
@@ -572,8 +572,8 @@ public static int getTotalLines(File file, int bufferSize) {
bufferSize = 1024;
}
try (InputStream is = getInputStream(file)) {
byte[] c = new byte[bufferSize];
int readChars = is.read(c);
byte[] chars = new byte[bufferSize];
int readChars = is.read(chars);
if (readChars == -1) {
// 空文件,返回0
return 0;
@@ -584,23 +584,35 @@ public static int getTotalLines(File file, int bufferSize) {
// 如果多行,最后一行无换行符,最后一行需要单独计数
// 如果多行,最后一行有换行符,则空行算作一行
int count = 1;
byte pre;
byte c = 0;
while (readChars == bufferSize) {
for (int i = 0; i < bufferSize; i++) {
if (c[i] == CharUtil.LF) {
pre = c;
c = chars[i];
// 换行符兼容MAC
if (c == CharUtil.LF || pre == CharUtil.CR) {
++count;
}
}
readChars = is.read(c);
readChars = is.read(chars);
}

// count remaining characters
while (readChars != -1) {
for (int i = 0; i < readChars; i++) {
if (c[i] == CharUtil.LF) {
pre = c;
c = chars[i];
if (c == CharUtil.LF || pre == CharUtil.CR) {
++count;
}
}
readChars = is.read(c);
readChars = is.read(chars);
}

// 最后一个字符为换行符,则单独计数行
if(c == CharUtil.CR){
++count;
}

return count;
9 changes: 6 additions & 3 deletions hutool-core/src/main/java/cn/hutool/core/lang/tree/Tree.java
Original file line number Diff line number Diff line change
@@ -315,22 +315,25 @@ public String toString() {
*/
public Tree<T> cloneTree() {
final Tree<T> result = ObjectUtil.clone(this);
result.setChildren(cloneChildren());
result.setChildren(cloneChildren(result));
return result;
}

/**
* 递归复制子节点
*
* @param parent 新的父节点
* @return 新的子节点列表
*/
private List<Tree<T>> cloneChildren() {
private List<Tree<T>> cloneChildren(final Tree<T> parent) {
final List<Tree<T>> children = getChildren();
if (null == children) {
return null;
}
final List<Tree<T>> newChildren = new ArrayList<>(children.size());
children.forEach((t) -> newChildren.add(t.cloneTree()));
children.forEach((t) -> {
newChildren.add(t.cloneTree().setParent(parent));
});
return newChildren;
}

41 changes: 41 additions & 0 deletions hutool-core/src/test/java/cn/hutool/core/bean/Issue3702Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cn.hutool.core.bean;

import cn.hutool.core.bean.copier.CopyOptions;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

/**
* setFieldValueEditor编辑后的值理应继续判断ignoreNullValue
*/
public class Issue3702Test {
@Test
void mapToMapTest() {
Map<String,String> map= new HashMap<>();
map.put("a","");
map.put("b","b");
map.put("c","c");
map.put("d","d");

Map<String,String> map2= new HashMap<>();
map2.put("a","a1");
map2.put("b","b1");
map2.put("c","c1");
map2.put("d","d1");

CopyOptions option= CopyOptions.create()
.setIgnoreNullValue(true)
.setIgnoreError(true)
.setFieldValueEditor((name, value)->{
if(value.equals("")){
value=null;
}
return value;
});
BeanUtil.copyProperties(map,map2,option);
Assertions.assertEquals("{a=a1, b=b, c=c, d=d}", map2.toString());
System.out.println(map2);
}
}
Loading