diff --git a/CHANGELOG.2.10.md b/CHANGELOG.2.10.md index 2eb9cc41c..b74e7bd1e 100644 --- a/CHANGELOG.2.10.md +++ b/CHANGELOG.2.10.md @@ -1,5 +1,3 @@ - - ## 2.10.0 ### 🐣 新增功能 @@ -19,4 +17,5 @@ 4. 【all】删除 项目内存监控页面 5. 【all】配置文件名称由 `extConfig.yml` 变更为 `application.yml` 6. 【all】调整项目打包目录结构 -7. 【all】取消兼容低版本数据目录文件迁移(调试运行) \ No newline at end of file +7. 【all】取消兼容低版本数据目录文件迁移(调试运行) +8. 【all】取消自动识别文件编码格式模块 `auto-charset-jchardet` \ No newline at end of file diff --git a/modules/common/src/main/java/io/jpom/util/BaseFileTailWatcher.java b/modules/common/src/main/java/io/jpom/util/BaseFileTailWatcher.java index e8f21b7e2..afefde59e 100644 --- a/modules/common/src/main/java/io/jpom/util/BaseFileTailWatcher.java +++ b/modules/common/src/main/java/io/jpom/util/BaseFileTailWatcher.java @@ -27,7 +27,6 @@ import cn.hutool.core.io.file.Tailer; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.StrUtil; -import io.jpom.plugin.PluginFactory; import io.jpom.system.ExtConfigBean; import io.jpom.system.JpomRuntimeException; import lombok.extern.slf4j.Slf4j; @@ -39,9 +38,9 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.Method; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.util.HashSet; import java.util.Iterator; +import java.util.Optional; import java.util.Set; /** @@ -71,17 +70,7 @@ public abstract class BaseFileTailWatcher { public static Charset detectorCharset(File logFile) { Charset detSet = ExtConfigBean.getInstance().getLogFileCharset(); - if (detSet == null) { - try { - String charsetName = (String) PluginFactory.getPlugin("charset-detector").execute(logFile); - detSet = StrUtil.isEmpty(charsetName) ? CharsetUtil.CHARSET_UTF_8 : CharsetUtil.charset(charsetName); - } catch (Exception e) { - log.warn("自动识别文件编码格式错误:{}", e.getMessage()); - detSet = CharsetUtil.CHARSET_UTF_8; - } - detSet = (detSet == StandardCharsets.US_ASCII) ? CharsetUtil.CHARSET_UTF_8 : detSet; - } - return detSet; + return Optional.ofNullable(detSet).orElse(CharsetUtil.CHARSET_UTF_8); } protected void send(T session, String msg) { diff --git a/modules/server/pom.xml b/modules/server/pom.xml index c23f1a79f..921150d02 100644 --- a/modules/server/pom.xml +++ b/modules/server/pom.xml @@ -53,12 +53,6 @@ ${project.version} - - io.jpom.plugins - auto-charset-jchardet - ${project.version} - - org.java-websocket diff --git a/modules/sub-plugin/auto-charset-jchardet/pom.xml b/modules/sub-plugin/auto-charset-jchardet/pom.xml deleted file mode 100644 index d28d6fc31..000000000 --- a/modules/sub-plugin/auto-charset-jchardet/pom.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - jpom-plugins-parent - io.jpom.plugins - 2.9.20 - ../pom.xml - - 4.0.0 - auto-charset-jchardet - plugin-auto-charset-jchardet - - - 8 - 8 - - - - - - net.sourceforge.jchardet - jchardet - 1.0 - - - - io.jpom - common - provided - ${project.version} - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.1.1 - - - - - true - - ./ - - - - ${project.version} - - ${maven.build.timestamp} - ${project.artifactId} - https://gitee.com/dromara/Jpom - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - - - false - - script/release.xml - - - - - - - make-assembly - package - - single - - - - - - - diff --git a/modules/sub-plugin/auto-charset-jchardet/script/release.xml b/modules/sub-plugin/auto-charset-jchardet/script/release.xml deleted file mode 100644 index c92996229..000000000 --- a/modules/sub-plugin/auto-charset-jchardet/script/release.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - release - false - - jar - - - - - / - false - true - runtime - - net.sourceforge.jchardet:jchardet - - - - - - - - ${project.build.directory}/classes - / - - - - diff --git a/modules/sub-plugin/auto-charset-jchardet/src/main/java/io/jpom/plugin/CharsetDetector.java b/modules/sub-plugin/auto-charset-jchardet/src/main/java/io/jpom/plugin/CharsetDetector.java deleted file mode 100644 index ff987d350..000000000 --- a/modules/sub-plugin/auto-charset-jchardet/src/main/java/io/jpom/plugin/CharsetDetector.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Code Technology Studio - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package io.jpom.plugin; - -import org.mozilla.intl.chardet.nsDetector; -import org.mozilla.intl.chardet.nsICharsetDetectionObserver; -import org.mozilla.intl.chardet.nsPSMDetector; - -import java.io.*; - -/** - * 文件编码识别器 - * - * @author Administrator - */ -public class CharsetDetector implements nsICharsetDetectionObserver { - - private boolean found = false; - private String result; - - public String detectChineseCharset(File file) throws IOException { - if (!file.exists()) { - throw new FileNotFoundException(file.getAbsolutePath()); - } - String[] val = detectChineseCharset(new FileInputStream(file)); - if (val == null || val.length <= 0) { - return null; - } - return val[0]; - } - - private String[] detectChineseCharset(InputStream in) throws IOException { - // Initalize the nsDetector() ; - nsDetector det = new nsDetector(nsPSMDetector.CHINESE); - // Set an observer... - // The Notify() will be called when a matching charset is found. - det.Init(this); - BufferedInputStream imp = new BufferedInputStream(in); - byte[] buf = new byte[1024]; - int len; - boolean isAscii = true; - while ((len = imp.read(buf, 0, buf.length)) != -1) { - // Check if the stream is only ascii. - if (isAscii) { - isAscii = det.isAscii(buf, len); - } - // DoIt if non-ascii and not done yet. - if (!isAscii) { - if (det.DoIt(buf, len, false)) { - break; - } - } - } - imp.close(); - in.close(); - det.DataEnd(); - String[] prob; - if (isAscii) { - found = true; - prob = new String[]{"ASCII"}; - } else if (found) { - prob = new String[]{result}; - } else { - prob = det.getProbableCharsets(); - } - return prob; - } - - @Override - public void Notify(String charset) { - found = true; - result = charset; - } -} diff --git a/modules/sub-plugin/auto-charset-jchardet/src/main/java/io/jpom/plugin/DefaultFileCharsetDetectorImpl.java b/modules/sub-plugin/auto-charset-jchardet/src/main/java/io/jpom/plugin/DefaultFileCharsetDetectorImpl.java deleted file mode 100644 index f23f3886c..000000000 --- a/modules/sub-plugin/auto-charset-jchardet/src/main/java/io/jpom/plugin/DefaultFileCharsetDetectorImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2019 Code Technology Studio - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package io.jpom.plugin; - -import java.io.File; -import java.util.Map; - -/** - * @author bwcx_jzy - * @since 2021/12/24 - */ -@PluginConfig(name = "charset-detector") -public class DefaultFileCharsetDetectorImpl implements IDefaultPlugin { - - @Override - public Object execute(Object main, Map parameter) throws Exception { - File file = (File) main; - return new CharsetDetector().detectChineseCharset(file); - } -} diff --git a/modules/sub-plugin/pom.xml b/modules/sub-plugin/pom.xml index cd313a078..af2bc03f1 100644 --- a/modules/sub-plugin/pom.xml +++ b/modules/sub-plugin/pom.xml @@ -38,7 +38,6 @@ email svn-clone maven-plugin - auto-charset-jchardet db-h2 docker-cli git-clone