Browse Source

sensitiveProcessor迁移到正确的方法

haibinxiao 5 years ago
parent
commit
11edc1fcc6
1 changed files with 2 additions and 2 deletions
  1. 2 2
      hutool-dfa/src/main/java/cn/hutool/dfa/SensitiveUtil.java

+ 2 - 2
hutool-dfa/src/main/java/cn/hutool/dfa/SensitiveUtil.java

@@ -190,8 +190,6 @@ public final class SensitiveUtil {
 	 * @return 敏感词过滤处理后的bean对象
 	 */
 	public static <T> T sensitiveFilter(T bean, boolean isGreedMatch, SensitiveProcessor sensitiveProcessor) {
-		sensitiveProcessor = sensitiveProcessor == null ? new SensitiveProcessor() {
-		} : sensitiveProcessor;
 		String jsonText = JSONUtil.toJsonStr(bean);
 		Class<T> c = (Class) bean.getClass();
 		return JSONUtil.toBean(sensitiveFilter(jsonText, isGreedMatch, sensitiveProcessor), c);
@@ -212,6 +210,8 @@ public final class SensitiveUtil {
 		if (CollectionUtil.isEmpty(foundWordList)) {
 			return text;
 		}
+		sensitiveProcessor = sensitiveProcessor == null ? new SensitiveProcessor() {
+		} : sensitiveProcessor;
 		Map<Integer, FoundWord> foundWordMap = new HashMap<>(foundWordList.size());
 		foundWordList.forEach(foundWord -> foundWordMap.put(foundWord.getStartIndex(), foundWord));
 		int length = text.length();