Looly 4 年之前
父节点
当前提交
51d0d118ac

+ 2 - 1
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创建失败资源未释放问题。
 
 -------------------------------------------------------------------------------------------------------------
 

+ 2 - 2
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 <code>&lt;[ [ ]]&gt;</code> 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 <code>&lt;[ [ ]]&gt;</code> 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.

+ 2 - 1
hutool-poi/pom.xml

@@ -40,10 +40,11 @@
 			<scope>compile</scope>
 			<optional>true</optional>
 		</dependency>
+		<!-- OFD -->
 		<dependency>
 			<groupId>org.ofdrw</groupId>
 			<artifactId>ofdrw-full</artifactId>
-			<version>1.7.2</version>
+			<version>1.7.3</version>
 			<scope>compile</scope>
 			<optional>true</optional>
 		</dependency>

+ 7 - 8
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 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 cn.hutool.core.io.FileUtil;
-import cn.hutool.core.io.IORuntimeException;
-import cn.hutool.poi.exceptions.POIException;
+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}
 	 */

+ 1 - 1
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

+ 14 - 12
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<ByteBuffer> 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;

+ 1 - 0
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;