修复TinyPinyinEngine可能的空指针问题

This commit is contained in:
Looly 2023-12-20 21:10:29 +08:00
parent cca184257a
commit 99ec3bbeb4
2 changed files with 5 additions and 1 deletions

View File

@ -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)

View File

@ -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;
@ -51,7 +53,8 @@ public class TinyPinyinEngine implements PinyinEngine {
@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();
}
}