Skip to content

Commit

Permalink
修复TinyPinyinEngine可能的空指针问题
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Dec 20, 2023
1 parent cca1842 commit 99ec3bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* 【core 】 修复JavaSourceCompiler.addSource目录处理错误问题(issue#3425@Github)
* 【core 】 修复时间戳转Bean时异常问题(issue#I8NMP7@Gitee)
* 【core 】 修复PostgreSQL使用upsert字段大小写问题问题(issue#I8PB4X@Gitee)
* 【extra 】 修复TinyPinyinEngine可能的空指针问题(issue#3437@Github)

-------------------------------------------------------------------------------------------------------------
# 5.8.23(2023-11-12)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package cn.hutool.extra.pinyin.engine.tinypinyin;

import cn.hutool.core.lang.Opt;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinEngine;
import com.github.promeg.pinyinhelper.Pinyin;

Expand Down Expand Up @@ -51,7 +53,8 @@ public String getPinyin(char c) {

@Override
public String getPinyin(String str, String separator) {
return Pinyin.toPinyin(str, separator).toLowerCase();
final String pinyin = Pinyin.toPinyin(str, separator);
return StrUtil.isEmpty(pinyin) ? pinyin : pinyin.toLowerCase();
}

}

0 comments on commit 99ec3bb

Please sign in to comment.