Skip to content

Commit 21d3dad

Browse files
committed
Prepare release
2 parents ced8bf8 + b8048c1 commit 21d3dad

File tree

55 files changed

+1012
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1012
-94
lines changed

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11

22
# 🚀Changelog
33

4+
-------------------------------------------------------------------------------------------------------------
5+
# 5.8.36(2025-02-18)
6+
7+
### 🐣新特性
8+
* 【crypto 】 增加BCUtil.decodeECPrivateKey方法(issue#3829@Github)
9+
* 【core 】 增加HtmlUtil.cleanEmptyTag方法(pr#3838@Github)
10+
* 【db 】 GlobalDbSetting优化默认配置读取规则,优先读取文件而非jar中的文件(issue#900@Github)
11+
* 【dfa 】 删除StopChar类中存在重复字符(pr#3841@Github)
12+
* 【http 】 支持鸿蒙设备 UA 解析(pr#1301@Gitee)
13+
14+
### 🐞Bug修复
15+
* 【aop 】 修复ProxyUtil可能的空指针问题(issue#IBF20Z@Gitee)
16+
* 【core 】 修复XmlUtil转义调用方法错误问题,修复XmlEscape未转义单引号问题(pr#3837@Github)
17+
* 【core 】 修复FileUtil.isAbsolutePath没有判断smb路径问题(pr#1299@Gitee)
18+
* 【core 】 修复AbstractFilter没有检查参数长度问题(issue#3854@Github)
19+
420
-------------------------------------------------------------------------------------------------------------
521
# 5.8.35(2024-12-25)
622

README-EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,18 @@ We provide the T-Shirt and Sweater with Hutool Logo, please visit the shop:
153153
<dependency>
154154
<groupId>cn.hutool</groupId>
155155
<artifactId>hutool-all</artifactId>
156-
<version>5.8.35</version>
156+
<version>5.8.36</version>
157157
</dependency>
158158
```
159159

160160
### 🍐Gradle
161161
```
162-
implementation 'cn.hutool:hutool-all:5.8.35'
162+
implementation 'cn.hutool:hutool-all:5.8.36'
163163
```
164164

165165
## 📥Download
166166

167-
- [Maven Repo](https://repo1.maven.org/maven2/cn/hutool/hutool-all/5.8.35/)
167+
- [Maven Repo](https://repo1.maven.org/maven2/cn/hutool/hutool-all/5.8.36/)
168168

169169
> 🔔️note:
170170
> Hutool 5.x supports JDK8+ and is not tested on Android platforms, and cannot guarantee that all tool classes or tool methods are available.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,20 @@ Hutool = Hu + tool,是原公司项目底层代码剥离后的开源库,“Hu
146146
<dependency>
147147
<groupId>cn.hutool</groupId>
148148
<artifactId>hutool-all</artifactId>
149-
<version>5.8.35</version>
149+
<version>5.8.36</version>
150150
</dependency>
151151
```
152152

153153
### 🍐Gradle
154154
```
155-
implementation 'cn.hutool:hutool-all:5.8.35'
155+
implementation 'cn.hutool:hutool-all:5.8.36'
156156
```
157157

158158
### 📥下载jar
159159

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

162-
- [Maven中央库](https://repo1.maven.org/maven2/cn/hutool/hutool-all/5.8.35/)
162+
- [Maven中央库](https://repo1.maven.org/maven2/cn/hutool/hutool-all/5.8.36/)
163163

164164
> 🔔️注意
165165
> Hutool 5.x支持JDK8+,对Android平台没有测试,不能保证所有工具类或工具方法可用。

bin/javadoc.sh

+5
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44

55
# 多模块聚合文档,生成在target/site/apidocs
66
exec mvn javadoc:aggregate
7+
8+
bin_home="$(dirname ${BASH_SOURCE[0]})"
9+
10+
# 拷贝自定义的index.html到聚合文档目录
11+
cp -vf $bin_home/../docs/apidocs/index.html $bin_home/../target/reports/apidocs/

bin/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.8.35
1+
5.8.36

docs/js/version.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
var version = '5.8.35'
1+
var version = '5.8.36'

hutool-all/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>cn.hutool</groupId>
1111
<artifactId>hutool-parent</artifactId>
12-
<version>5.8.35</version>
12+
<version>5.8.36</version>
1313
</parent>
1414

1515
<artifactId>hutool-all</artifactId>

hutool-aop/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>cn.hutool</groupId>
1111
<artifactId>hutool-parent</artifactId>
12-
<version>5.8.35</version>
12+
<version>5.8.36</version>
1313
</parent>
1414

1515
<artifactId>hutool-aop</artifactId>

hutool-aop/src/main/java/cn/hutool/aop/proxy/JdkProxyFactory.java

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
public class JdkProxyFactory extends ProxyFactory {
1313
private static final long serialVersionUID = 1L;
1414

15+
/**
16+
* 获取单例
17+
*/
18+
public static JdkProxyFactory INSTANCE = new JdkProxyFactory();
19+
1520
@Override
1621
public <T> T proxy(T target, Aspect aspect) {
1722
return ProxyUtil.newProxyInstance(//

hutool-aop/src/main/java/cn/hutool/aop/proxy/ProxyFactory.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ public static <T> T createProxy(T target, Class<? extends Aspect> aspectClass) {
5959
* @return 代理对象
6060
*/
6161
public static <T> T createProxy(T target, Aspect aspect) {
62-
return create().proxy(target, aspect);
62+
ProxyFactory factory = create();
63+
if(null == factory){
64+
// issue#IBF20Z
65+
// 可能的空指针问题
66+
factory = JdkProxyFactory.INSTANCE;
67+
}
68+
return factory.proxy(target, aspect);
6369
}
6470

6571
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package cn.hutool.aop.test;
2+
3+
import cn.hutool.aop.proxy.ProxyFactory;
4+
import cn.hutool.core.lang.Console;
5+
import cn.hutool.core.thread.ThreadUtil;
6+
import org.junit.jupiter.api.Test;
7+
8+
import java.util.concurrent.CountDownLatch;
9+
import java.util.concurrent.ExecutorService;
10+
import java.util.concurrent.atomic.AtomicInteger;
11+
12+
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
14+
public class IssueIBF20ZTest {
15+
16+
@Test
17+
public void testLoadFirstAvailableConcurrent() throws InterruptedException {
18+
// 创建一个固定大小的线程池
19+
int threadCount = 1000;
20+
ExecutorService executorService = ThreadUtil.newExecutor(threadCount);
21+
22+
// 创建一个 CountDownLatch,用于等待所有任务完成
23+
CountDownLatch latch = new CountDownLatch(threadCount);
24+
25+
// 计数器用于统计成功加载服务提供者的次数
26+
AtomicInteger successCount = new AtomicInteger(0);
27+
28+
// 提交多个任务到线程池
29+
for (int i = 0; i < threadCount; i++) {
30+
executorService.submit(() -> {
31+
ProxyFactory factory = ProxyFactory.create();
32+
if (factory != null) {
33+
Console.log(factory.getClass());
34+
successCount.incrementAndGet();
35+
}
36+
latch.countDown(); // 每个任务完成时,计数减一
37+
});
38+
}
39+
40+
// 等待所有任务完成
41+
latch.await();
42+
43+
// 关闭线程池并等待所有任务完成
44+
executorService.shutdown();
45+
46+
// 验证所有线程都成功加载了服务提供者
47+
assertEquals(threadCount, successCount.get());
48+
}
49+
}

hutool-bloomFilter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>cn.hutool</groupId>
1111
<artifactId>hutool-parent</artifactId>
12-
<version>5.8.35</version>
12+
<version>5.8.36</version>
1313
</parent>
1414

1515
<artifactId>hutool-bloomFilter</artifactId>

hutool-bloomFilter/src/main/java/cn/hutool/bloomfilter/filter/AbstractFilter.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import cn.hutool.bloomfilter.bitMap.BitMap;
55
import cn.hutool.bloomfilter.bitMap.IntMap;
66
import cn.hutool.bloomfilter.bitMap.LongMap;
7+
import cn.hutool.core.lang.Assert;
78

89
/**
910
* 抽象Bloom过滤器
@@ -46,7 +47,7 @@ public AbstractFilter(long maxValue) {
4647
* @param machineNum 机器位数
4748
*/
4849
public void init(long maxValue, int machineNum) {
49-
this.size = maxValue;
50+
this.size = Assert.checkBetween(maxValue, 1, Integer.MAX_VALUE);
5051
switch (machineNum) {
5152
case BitMap.MACHINE32:
5253
bm = new IntMap((int) (size / machineNum));

hutool-bom/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>cn.hutool</groupId>
1111
<artifactId>hutool-parent</artifactId>
12-
<version>5.8.35</version>
12+
<version>5.8.36</version>
1313
</parent>
1414

1515
<artifactId>hutool-bom</artifactId>

hutool-cache/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>cn.hutool</groupId>
1111
<artifactId>hutool-parent</artifactId>
12-
<version>5.8.35</version>
12+
<version>5.8.36</version>
1313
</parent>
1414

1515
<artifactId>hutool-cache</artifactId>

hutool-captcha/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>cn.hutool</groupId>
1111
<artifactId>hutool-parent</artifactId>
12-
<version>5.8.35</version>
12+
<version>5.8.36</version>
1313
</parent>
1414

1515
<artifactId>hutool-captcha</artifactId>

hutool-core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>cn.hutool</groupId>
1111
<artifactId>hutool-parent</artifactId>
12-
<version>5.8.35</version>
12+
<version>5.8.36</version>
1313
</parent>
1414

1515
<artifactId>hutool-core</artifactId>

hutool-core/src/main/java/cn/hutool/core/io/FileUtil.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public class FileUtil extends PathUtil {
6464
*/
6565
private static final Pattern PATTERN_PATH_ABSOLUTE = Pattern.compile("^[a-zA-Z]:([/\\\\].*)?", Pattern.DOTALL);
6666

67+
/**
68+
* windows的共享文件夹开头
69+
*/
70+
private static final String SMB_PATH_PREFIX = "\\\\";
6771

6872
/**
6973
* 是否为Windows环境
@@ -1370,6 +1374,7 @@ public static String getAbsolutePath(File file) {
13701374
* <li>以/开头的路径</li>
13711375
* <li>满足类似于 c:/xxxxx,其中祖母随意,不区分大小写</li>
13721376
* <li>满足类似于 d:\xxxxx,其中祖母随意,不区分大小写</li>
1377+
* <li>满足windows SMB协议格式,如: \\192.168.254.1\Share</li>
13731378
* </ul>
13741379
*
13751380
* @param path 需要检查的Path
@@ -1381,7 +1386,7 @@ public static boolean isAbsolutePath(String path) {
13811386
}
13821387

13831388
// 给定的路径已经是绝对路径了
1384-
return StrUtil.C_SLASH == path.charAt(0) || ReUtil.isMatch(PATTERN_PATH_ABSOLUTE, path);
1389+
return StrUtil.C_SLASH == path.charAt(0) || path.startsWith(SMB_PATH_PREFIX) || ReUtil.isMatch(PATTERN_PATH_ABSOLUTE, path);
13851390
}
13861391

13871392
/**
@@ -1667,7 +1672,7 @@ public static String normalize(String path) {
16671672
}
16681673

16691674
//兼容Windows下的共享目录路径(原始路径如果以\\开头,则保留这种路径)
1670-
if (path.startsWith("\\\\")) {
1675+
if (path.startsWith(SMB_PATH_PREFIX)) {
16711676
return path;
16721677
}
16731678

hutool-core/src/main/java/cn/hutool/core/io/resource/FileResource.java

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public URL getUrl(){
7979

8080
@Override
8181
public InputStream getStream() throws NoResourceException {
82+
if (!this.file.exists()) {
83+
throw new NoResourceException("File [{}] not exist!", this.file.getAbsolutePath());
84+
}
8285
return FileUtil.getInputStream(this.file);
8386
}
8487

hutool-core/src/main/java/cn/hutool/core/text/escape/Html4Escape.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cn.hutool.core.text.escape;
22

33
import cn.hutool.core.text.replacer.LookupReplacer;
4+
import cn.hutool.core.text.replacer.ReplacerChain;
45

56
/**
67
* HTML4的ESCAPE
@@ -9,9 +10,21 @@
910
* @author looly
1011
*
1112
*/
12-
public class Html4Escape extends XmlEscape {
13+
public class Html4Escape extends ReplacerChain {
1314
private static final long serialVersionUID = 1L;
1415

16+
/**
17+
* HTML转义字符<br>
18+
* HTML转义相比XML,并不转义单引号<br>
19+
* 见:https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents
20+
*/
21+
protected static final String[][] BASIC_ESCAPE = { //
22+
{"\"", "&quot;"}, // " - double-quote
23+
{"&", "&amp;"}, // & - ampersand
24+
{"<", "&lt;"}, // < - less-than
25+
{">", "&gt;"}, // > - greater-than
26+
};
27+
1528
protected static final String[][] ISO8859_1_ESCAPE = { //
1629
{ "\u00A0", "&nbsp;" }, // non-breaking space
1730
{ "\u00A1", "&iexcl;" }, // inverted exclamation mark
@@ -310,6 +323,7 @@ public class Html4Escape extends XmlEscape {
310323

311324
public Html4Escape() {
312325
super();
326+
addChain(new LookupReplacer(BASIC_ESCAPE));
313327
addChain(new LookupReplacer(ISO8859_1_ESCAPE));
314328
addChain(new LookupReplacer(HTML40_EXTENDED_ESCAPE));
315329
}

hutool-core/src/main/java/cn/hutool/core/text/escape/XmlEscape.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class XmlEscape extends ReplacerChain {
2222
private static final long serialVersionUID = 1L;
2323

2424
protected static final String[][] BASIC_ESCAPE = { //
25-
// {"'", "&apos;"}, // " - single-quote
25+
{"'", "&apos;"}, // " - single-quote
2626
{"\"", "&quot;"}, // " - double-quote
2727
{"&", "&amp;"}, // & - ampersand
2828
{"<", "&lt;"}, // < - less-than

hutool-core/src/main/java/cn/hutool/core/text/escape/XmlUnescape.java

-3
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ public class XmlUnescape extends ReplacerChain {
1313
private static final long serialVersionUID = 1L;
1414

1515
protected static final String[][] BASIC_UNESCAPE = InternalEscapeUtil.invert(XmlEscape.BASIC_ESCAPE);
16-
// issue#1118
17-
protected static final String[][] OTHER_UNESCAPE = new String[][]{new String[]{"&apos;", "'"}};
1816

1917
/**
2018
* 构造
2119
*/
2220
public XmlUnescape() {
2321
addChain(new LookupReplacer(BASIC_UNESCAPE));
2422
addChain(new NumericEntityUnescaper());
25-
addChain(new LookupReplacer(OTHER_UNESCAPE));
2623
}
2724
}

hutool-core/src/main/java/cn/hutool/core/util/XmlUtil.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -956,14 +956,15 @@ public static Object getByXPath(String expression, Object source, QName returnTy
956956
* &lt; (小于) 替换为 &amp;lt;
957957
* &gt; (大于) 替换为 &amp;gt;
958958
* &quot; (双引号) 替换为 &amp;quot;
959+
* ' (单引号) 替换为 &amp;apos;
959960
* </pre>
960961
*
961962
* @param string 被替换的字符串
962963
* @return 替换后的字符串
963964
* @since 4.0.8
964965
*/
965966
public static String escape(String string) {
966-
return EscapeUtil.escapeHtml4(string);
967+
return EscapeUtil.escapeXml(string);
967968
}
968969

969970
/**
@@ -975,7 +976,7 @@ public static String escape(String string) {
975976
* @since 5.0.6
976977
*/
977978
public static String unescape(String string) {
978-
return EscapeUtil.unescapeHtml4(string);
979+
return EscapeUtil.unescapeXml(string);
979980
}
980981

981982
/**

0 commit comments

Comments
 (0)