mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix bug and add timeout
This commit is contained in:
parent
30692987ff
commit
60a068db3f
@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.8.3.M1 (2022-05-27)
|
# 5.8.3.M1 (2022-05-30)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
|
* 【extra 】 mail增加writeTimeout参数支持(issue#2355@Github)
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
|
* 【core 】 修复NumberUtil.isXXX空判断错误(issue#2356@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1238,12 +1238,13 @@ public class NumberUtil {
|
|||||||
* @return 是否为整数
|
* @return 是否为整数
|
||||||
*/
|
*/
|
||||||
public static boolean isInteger(String s) {
|
public static boolean isInteger(String s) {
|
||||||
if(StrUtil.isNotBlank(s)) {
|
if(StrUtil.isBlank(s)) {
|
||||||
try {
|
return false;
|
||||||
Integer.parseInt(s);
|
}
|
||||||
} catch (NumberFormatException e) {
|
try {
|
||||||
return false;
|
Integer.parseInt(s);
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1257,12 +1258,13 @@ public class NumberUtil {
|
|||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
public static boolean isLong(String s) {
|
public static boolean isLong(String s) {
|
||||||
if(StrUtil.isNotBlank(s)) {
|
if(StrUtil.isBlank(s)) {
|
||||||
try {
|
return false;
|
||||||
Long.parseLong(s);
|
}
|
||||||
} catch (NumberFormatException e) {
|
try {
|
||||||
return false;
|
Long.parseLong(s);
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1274,15 +1276,16 @@ public class NumberUtil {
|
|||||||
* @return 是否为{@link Double}类型
|
* @return 是否为{@link Double}类型
|
||||||
*/
|
*/
|
||||||
public static boolean isDouble(String s) {
|
public static boolean isDouble(String s) {
|
||||||
if(StrUtil.isNotBlank(s)) {
|
if(StrUtil.isBlank(s)) {
|
||||||
try {
|
return false;
|
||||||
Double.parseDouble(s);
|
|
||||||
return s.contains(".");
|
|
||||||
} catch (NumberFormatException ignore) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
try {
|
||||||
|
Double.parseDouble(s);
|
||||||
|
return s.contains(".");
|
||||||
|
} catch (NumberFormatException ignore) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,6 +61,9 @@ public class NumberUtilTest {
|
|||||||
Assert.assertTrue(NumberUtil.isInteger("0256"));
|
Assert.assertTrue(NumberUtil.isInteger("0256"));
|
||||||
Assert.assertTrue(NumberUtil.isInteger("0"));
|
Assert.assertTrue(NumberUtil.isInteger("0"));
|
||||||
Assert.assertFalse(NumberUtil.isInteger("23.4"));
|
Assert.assertFalse(NumberUtil.isInteger("23.4"));
|
||||||
|
Assert.assertFalse(NumberUtil.isInteger(null));
|
||||||
|
Assert.assertFalse(NumberUtil.isInteger(""));
|
||||||
|
Assert.assertFalse(NumberUtil.isInteger(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -70,6 +73,9 @@ public class NumberUtilTest {
|
|||||||
Assert.assertTrue(NumberUtil.isLong("0256"));
|
Assert.assertTrue(NumberUtil.isLong("0256"));
|
||||||
Assert.assertTrue(NumberUtil.isLong("0"));
|
Assert.assertTrue(NumberUtil.isLong("0"));
|
||||||
Assert.assertFalse(NumberUtil.isLong("23.4"));
|
Assert.assertFalse(NumberUtil.isLong("23.4"));
|
||||||
|
Assert.assertFalse(NumberUtil.isLong(null));
|
||||||
|
Assert.assertFalse(NumberUtil.isLong(""));
|
||||||
|
Assert.assertFalse(NumberUtil.isLong(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -23,8 +23,9 @@ public class MailAccount implements Serializable {
|
|||||||
private static final String SMTP_HOST = "mail.smtp.host";
|
private static final String SMTP_HOST = "mail.smtp.host";
|
||||||
private static final String SMTP_PORT = "mail.smtp.port";
|
private static final String SMTP_PORT = "mail.smtp.port";
|
||||||
private static final String SMTP_AUTH = "mail.smtp.auth";
|
private static final String SMTP_AUTH = "mail.smtp.auth";
|
||||||
private static final String SMTP_CONNECTION_TIMEOUT = "mail.smtp.connectiontimeout";
|
|
||||||
private static final String SMTP_TIMEOUT = "mail.smtp.timeout";
|
private static final String SMTP_TIMEOUT = "mail.smtp.timeout";
|
||||||
|
private static final String SMTP_CONNECTION_TIMEOUT = "mail.smtp.connectiontimeout";
|
||||||
|
private static final String SMTP_WRITE_TIMEOUT = "mail.smtp.writetimeout";
|
||||||
|
|
||||||
// SSL
|
// SSL
|
||||||
private static final String STARTTLS_ENABLE = "mail.smtp.starttls.enable";
|
private static final String STARTTLS_ENABLE = "mail.smtp.starttls.enable";
|
||||||
@ -121,6 +122,10 @@ public class MailAccount implements Serializable {
|
|||||||
* Socket连接超时值,单位毫秒,缺省值不超时
|
* Socket连接超时值,单位毫秒,缺省值不超时
|
||||||
*/
|
*/
|
||||||
private long connectionTimeout;
|
private long connectionTimeout;
|
||||||
|
/**
|
||||||
|
* Socket写出超时值,单位毫秒,缺省值不超时
|
||||||
|
*/
|
||||||
|
private long writeTimeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义的其他属性,此自定义属性会覆盖默认属性
|
* 自定义的其他属性,此自定义属性会覆盖默认属性
|
||||||
@ -518,6 +523,18 @@ public class MailAccount implements Serializable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置Socket写出超时值,单位毫秒,缺省值不超时
|
||||||
|
*
|
||||||
|
* @param writeTimeout Socket写出超时值,单位毫秒,缺省值不超时
|
||||||
|
* @return this
|
||||||
|
* @since 5.8.3
|
||||||
|
*/
|
||||||
|
public MailAccount setWriteTimeout(long writeTimeout) {
|
||||||
|
this.writeTimeout = writeTimeout;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取自定义属性列表
|
* 获取自定义属性列表
|
||||||
*
|
*
|
||||||
@ -563,6 +580,10 @@ public class MailAccount implements Serializable {
|
|||||||
if (this.connectionTimeout > 0) {
|
if (this.connectionTimeout > 0) {
|
||||||
p.put(SMTP_CONNECTION_TIMEOUT, String.valueOf(this.connectionTimeout));
|
p.put(SMTP_CONNECTION_TIMEOUT, String.valueOf(this.connectionTimeout));
|
||||||
}
|
}
|
||||||
|
// issue#2355
|
||||||
|
if (this.writeTimeout > 0) {
|
||||||
|
p.put(SMTP_WRITE_TIMEOUT, String.valueOf(this.writeTimeout));
|
||||||
|
}
|
||||||
|
|
||||||
p.put(MAIL_DEBUG, String.valueOf(this.debug));
|
p.put(MAIL_DEBUG, String.valueOf(this.debug));
|
||||||
|
|
||||||
|
@ -38,3 +38,5 @@ splitlongparameters = false
|
|||||||
timeout = 0
|
timeout = 0
|
||||||
# Socket连接超时值,单位毫秒,缺省值不超时
|
# Socket连接超时值,单位毫秒,缺省值不超时
|
||||||
connectionTimeout = 0
|
connectionTimeout = 0
|
||||||
|
# Socket写出超时值,单位毫秒,缺省值不超时
|
||||||
|
writeTimeout = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user