release branch 0.16.0

This commit is contained in:
binbin.hou
2024-04-26 17:42:14 +08:00
parent fafb4e4151
commit e8c47ac7d2
11 changed files with 86 additions and 9 deletions

View File

@@ -298,3 +298,9 @@
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|:---|:-----|---------------------|:-------------------|:-------------------------------------------------|
| 1 | F | 调整默认文件名称,避免和其他框架重合。 | 2024-4-23 21:02:25 | https://github.com/houbb/sensitive-word/issues/54 |
# release_0.16.0
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|:---|:-----|----------------------|:-------------------|:-------------------------------------------------|
| 1 | F | 支持资源的释放,如 andriod 场景 | 2024-4-26 21:02:25 | https://github.com/houbb/sensitive-word/issues/53 |

View File

@@ -52,9 +52,9 @@
[CHANGE_LOG.md](https://github.com/houbb/sensitive-word/blob/master/CHANGE_LOG.md)
V0.15.0:
V0.16.0:
- [x] 修复 [#54](https://github.com/houbb/sensitive-word/issues/54)
- [x] 支持内存释放 [#53](https://github.com/houbb/sensitive-word/issues/53)
## 更多资料
@@ -86,7 +86,7 @@ V0.15.0:
<dependency>
<groupId>com.github.houbb</groupId>
<artifactId>sensitive-word</artifactId>
<version>0.15.0</version>
<version>0.16.0</version>
</dependency>
```
@@ -450,6 +450,19 @@ Assert.assertTrue(wordBs.contains(text));
| 13 | charIgnore | 忽略的字符 | none |
| 14 | wordResultCondition | 针对匹配的敏感词额外加工,比如可以限制英文单词必须全匹配 | 恒为真 |
## 内存的释放
有时候我们需要释放内存,可以如下:
> [关于内存回收问题](https://github.com/houbb/sensitive-word/issues/53)
```java
SensitiveWordBs wordBs = SensitiveWordBs.newInstance()
.init();
// 后续因为一些原因移除了对应信息,希望释放内存。
wordBs.destroy();
```
# wordResultCondition-针对匹配词进一步判断
## 说明

View File

@@ -6,7 +6,7 @@
<groupId>com.github.houbb</groupId>
<artifactId>sensitive-word</artifactId>
<version>0.15.0</version>
<version>0.16.0</version>
<properties>
<!--============================== All Plugins START ==============================-->

View File

@@ -10,9 +10,9 @@ ECHO "============================= RELEASE START..."
:: 版本号信息(需要手动指定)
:::: 旧版本名称
SET version=0.15.0
SET version=0.16.0
:::: 新版本名称
SET newVersion=0.16.0
SET newVersion=0.17.0
:::: 组织名称
SET groupName=com.github.houbb
:::: 项目名称

View File

@@ -0,0 +1,11 @@
package com.github.houbb.sensitive.word.api;
public interface ISensitiveWordDestroy {
/**
* 资源的销毁
* @since 0.16.0
*/
void destroy();
}

View File

@@ -11,7 +11,7 @@ import java.util.Collection;
* @author binbin.hou
* @since 0.0.1
*/
public interface IWordData {
public interface IWordData extends ISensitiveWordDestroy {
/**

View File

@@ -32,7 +32,7 @@ import java.util.Set;
* @author binbin.hou
* @since 0.0.1
*/
public class SensitiveWordBs {
public class SensitiveWordBs implements ISensitiveWordDestroy {
/**
* 私有化构造器
@@ -573,6 +573,11 @@ public class SensitiveWordBs {
return wordTag.getTag(word);
}
@Override
public void destroy() {
}
//------------------------------------------------------------------------------------ 公开方法 END
}

View File

@@ -183,4 +183,11 @@ public class WordDataHashMap extends AbstractWordData {
return currentMap;
}
@Override
public synchronized void destroy() {
if(innerWordMap != null) {
innerWordMap.clear();
}
}
}

View File

@@ -117,4 +117,10 @@ public class WordDataTree implements IWordData {
return currentMap;
}
@Override
public void destroy() {
if(this.root != null) {
this.root.destroy();
}
}
}

View File

@@ -1,5 +1,7 @@
package com.github.houbb.sensitive.word.support.data;
import com.github.houbb.sensitive.word.api.ISensitiveWordDestroy;
import java.util.HashMap;
import java.util.Map;
@@ -8,7 +10,7 @@ import java.util.Map;
*
* @since 0.7.0
*/
public class WordDataTreeNode {
public class WordDataTreeNode implements ISensitiveWordDestroy {
/**
* 关键词结束标识
@@ -46,4 +48,11 @@ public class WordDataTreeNode {
return this;
}
@Override
public void destroy() {
if(subNodeMap != null) {
subNodeMap.clear();
}
}
}

View File

@@ -0,0 +1,20 @@
package com.github.houbb.sensitive.word.bs;
import org.junit.Test;
/**
* 资源的销毁
*
* @since 0.16.0
*/
public class SensitiveWordBsDestroyTest {
@Test
public void destroyTest() {
SensitiveWordBs wordBs = SensitiveWordBs.newInstance()
.init();
// 后续因为一些原因移除了对应信息,希望释放内存。
wordBs.destroy();
}
}