diff --git a/CHANGELOG.md b/CHANGELOG.md index 05066f2e5..5e52baac8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,13 @@ ------------------------------------------------------------------------------------------------------------- -# 5.6.0 (2021-02-27) +# 5.6.0 (2021-02-28) ### 新特性 * 【poi 】 重要:不再兼容POI-3.x,增加兼容POI-5.x(issue#I35J6B@Gitee) ### Bug修复 +* 【socket 】 修复Client创建失败资源未释放问题。 ------------------------------------------------------------------------------------------------------------- diff --git a/hutool-json/src/main/java/cn/hutool/json/XML.java b/hutool-json/src/main/java/cn/hutool/json/XML.java index 9687112dc..7dee8ef99 100644 --- a/hutool-json/src/main/java/cn/hutool/json/XML.java +++ b/hutool-json/src/main/java/cn/hutool/json/XML.java @@ -62,7 +62,7 @@ public class XML { /** * 转换XML为JSONObject * 转换过程中一些信息可能会丢失,JSON中无法区分节点和属性,相同的节点将被处理为JSONArray。 - * Content text may be placed in a "content" member. Comments, prologs, DTDs, and <[ [ ]]> are ignored. + * Content text may be placed in a "content" member. Comments, prologs, DTDs, and {@code <[ [ ]]>} are ignored. * * @param string The source string. * @return A JSONObject containing the structured data from the XML string. @@ -75,7 +75,7 @@ public class XML { /** * 转换XML为JSONObject * 转换过程中一些信息可能会丢失,JSON中无法区分节点和属性,相同的节点将被处理为JSONArray。 - * Content text may be placed in a "content" member. Comments, prologs, DTDs, and <[ [ ]]> are ignored. + * Content text may be placed in a "content" member. Comments, prologs, DTDs, and {@code <[ [ ]]>} are ignored. * All values are converted as strings, for 1, 01, 29.0 will not be coerced to numbers but will instead be the exact value as seen in the XML document. * * @param string The source string. diff --git a/hutool-poi/pom.xml b/hutool-poi/pom.xml index d5dd22f65..75757aa85 100644 --- a/hutool-poi/pom.xml +++ b/hutool-poi/pom.xml @@ -40,10 +40,11 @@ compile true + org.ofdrw ofdrw-full - 1.7.2 + 1.7.3 compile true diff --git a/hutool-poi/src/main/java/cn/hutool/poi/word/DocUtil.java b/hutool-poi/src/main/java/cn/hutool/poi/word/DocUtil.java index 1eb1c72f1..fb7e6fbbd 100644 --- a/hutool-poi/src/main/java/cn/hutool/poi/word/DocUtil.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/word/DocUtil.java @@ -1,19 +1,18 @@ package cn.hutool.poi.word; -import java.io.File; -import java.io.IOException; - -import org.apache.poi.openxml4j.exceptions.InvalidFormatException; -import org.apache.poi.openxml4j.opc.OPCPackage; -import org.apache.poi.xwpf.usermodel.XWPFDocument; - import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IORuntimeException; import cn.hutool.poi.exceptions.POIException; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.xwpf.usermodel.XWPFDocument; + +import java.io.File; +import java.io.IOException; /** * Word Document工具 - * + * * @author looly * @since 4.4.1 */ @@ -21,7 +20,7 @@ public class DocUtil { /** * 创建{@link XWPFDocument},如果文件已存在则读取之,否则创建新的 - * + * * @param file docx文件 * @return {@link XWPFDocument} */ diff --git a/hutool-poi/src/main/java/cn/hutool/poi/word/Word07Writer.java b/hutool-poi/src/main/java/cn/hutool/poi/word/Word07Writer.java index 48bb446f6..837a57a7b 100644 --- a/hutool-poi/src/main/java/cn/hutool/poi/word/Word07Writer.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/word/Word07Writer.java @@ -21,7 +21,7 @@ import java.io.InputStream; import java.io.OutputStream; /** - * Word生成器 + * Word docx生成器 * * @author looly * @since 4.4.1 diff --git a/hutool-socket/src/main/java/cn/hutool/socket/aio/AioClient.java b/hutool-socket/src/main/java/cn/hutool/socket/aio/AioClient.java index 9c9505e75..2fb37713d 100644 --- a/hutool-socket/src/main/java/cn/hutool/socket/aio/AioClient.java +++ b/hutool-socket/src/main/java/cn/hutool/socket/aio/AioClient.java @@ -1,5 +1,11 @@ package cn.hutool.socket.aio; +import cn.hutool.core.io.IORuntimeException; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.thread.ThreadFactoryBuilder; +import cn.hutool.socket.SocketConfig; +import cn.hutool.socket.SocketRuntimeException; + import java.io.Closeable; import java.io.IOException; import java.net.InetSocketAddress; @@ -9,14 +15,9 @@ import java.nio.channels.AsynchronousChannelGroup; import java.nio.channels.AsynchronousSocketChannel; import java.util.concurrent.ExecutionException; -import cn.hutool.core.io.IORuntimeException; -import cn.hutool.core.thread.ThreadFactoryBuilder; -import cn.hutool.socket.SocketConfig; -import cn.hutool.socket.SocketRuntimeException; - /** * Aio Socket客户端 - * + * * @author looly * @since 4.5.0 */ @@ -26,7 +27,7 @@ public class AioClient implements Closeable{ /** * 构造 - * + * * @param address 地址 * @param ioAction IO处理类 */ @@ -36,7 +37,7 @@ public class AioClient implements Closeable{ /** * 构造 - * + * * @param address 地址 * @param ioAction IO处理类 * @param config 配置项 @@ -47,7 +48,7 @@ public class AioClient implements Closeable{ /** * 构造 - * + * * @param channel {@link AsynchronousSocketChannel} * @param ioAction IO处理类 * @param config 配置项 @@ -74,7 +75,7 @@ public class AioClient implements Closeable{ /** * 获取IO处理器 - * + * * @return {@link IoAction} */ public IoAction getIoAction() { @@ -83,7 +84,7 @@ public class AioClient implements Closeable{ /** * 从服务端读取数据 - * + * * @return this */ public AioClient read() { @@ -113,7 +114,7 @@ public class AioClient implements Closeable{ // ------------------------------------------------------------------------------------- Private method start /** * 初始化 - * + * * @param address 地址和端口 * @param poolSize 线程池大小 * @return this @@ -134,6 +135,7 @@ public class AioClient implements Closeable{ try { channel.connect(address).get(); } catch (InterruptedException | ExecutionException e) { + IoUtil.close(channel); throw new SocketRuntimeException(e); } return channel; diff --git a/hutool-socket/src/main/java/cn/hutool/socket/nio/NioClient.java b/hutool-socket/src/main/java/cn/hutool/socket/nio/NioClient.java index b235b1bdd..f56bd531d 100644 --- a/hutool-socket/src/main/java/cn/hutool/socket/nio/NioClient.java +++ b/hutool-socket/src/main/java/cn/hutool/socket/nio/NioClient.java @@ -66,6 +66,7 @@ public class NioClient implements Closeable { //noinspection StatementWithEmptyBody while (false == channel.finishConnect()){} } catch (IOException e) { + close(); throw new IORuntimeException(e); } return this;