mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-24 18:04:54 +08:00
fix bug
This commit is contained in:
parent
e1437f9b65
commit
28a565da25
@ -1242,12 +1242,13 @@ public class NumberUtil {
|
||||
* @return 是否为整数
|
||||
*/
|
||||
public static boolean isInteger(final String s) {
|
||||
if(StrUtil.isNotBlank(s)) {
|
||||
try {
|
||||
Integer.parseInt(s);
|
||||
} catch (final NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
if(StrUtil.isBlank(s)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Integer.parseInt(s);
|
||||
} catch (final NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1261,12 +1262,13 @@ public class NumberUtil {
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public static boolean isLong(final String s) {
|
||||
if (StrUtil.isNotBlank(s)) {
|
||||
try {
|
||||
Long.parseLong(s);
|
||||
} catch (final NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
if(StrUtil.isBlank(s)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Long.parseLong(s);
|
||||
} catch (final NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1278,15 +1280,16 @@ public class NumberUtil {
|
||||
* @return 是否为{@link Double}类型
|
||||
*/
|
||||
public static boolean isDouble(final String s) {
|
||||
if (StrUtil.isNotBlank(s)) {
|
||||
try {
|
||||
Double.parseDouble(s);
|
||||
return s.contains(".");
|
||||
} catch (final NumberFormatException ignore) {
|
||||
// ignore
|
||||
}
|
||||
if(StrUtil.isBlank(s)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
try {
|
||||
Double.parseDouble(s);
|
||||
return s.contains(".");
|
||||
} catch (final NumberFormatException ignore) {
|
||||
// ignore
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,6 +62,9 @@ public class NumberUtilTest {
|
||||
Assert.assertTrue(NumberUtil.isInteger("0256"));
|
||||
Assert.assertTrue(NumberUtil.isInteger("0"));
|
||||
Assert.assertFalse(NumberUtil.isInteger("23.4"));
|
||||
Assert.assertFalse(NumberUtil.isInteger(null));
|
||||
Assert.assertFalse(NumberUtil.isInteger(""));
|
||||
Assert.assertFalse(NumberUtil.isInteger(" "));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -71,6 +74,9 @@ public class NumberUtilTest {
|
||||
Assert.assertTrue(NumberUtil.isLong("0256"));
|
||||
Assert.assertTrue(NumberUtil.isLong("0"));
|
||||
Assert.assertFalse(NumberUtil.isLong("23.4"));
|
||||
Assert.assertFalse(NumberUtil.isLong(null));
|
||||
Assert.assertFalse(NumberUtil.isLong(""));
|
||||
Assert.assertFalse(NumberUtil.isLong(" "));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -23,8 +23,9 @@ public class MailAccount implements Serializable {
|
||||
private static final String SMTP_HOST = "mail.smtp.host";
|
||||
private static final String SMTP_PORT = "mail.smtp.port";
|
||||
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_CONNECTION_TIMEOUT = "mail.smtp.connectiontimeout";
|
||||
private static final String SMTP_WRITE_TIMEOUT = "mail.smtp.writetimeout";
|
||||
|
||||
// SSL
|
||||
private static final String STARTTLS_ENABLE = "mail.smtp.starttls.enable";
|
||||
@ -117,11 +118,17 @@ public class MailAccount implements Serializable {
|
||||
* SMTP超时时长,单位毫秒,缺省值不超时
|
||||
*/
|
||||
private long timeout;
|
||||
|
||||
/**
|
||||
* Socket连接超时值,单位毫秒,缺省值不超时
|
||||
*/
|
||||
private long connectionTimeout;
|
||||
|
||||
/**
|
||||
* Socket写出超时值,单位毫秒,缺省值不超时
|
||||
*/
|
||||
private long writeTimeout;
|
||||
|
||||
/**
|
||||
* 自定义的其他属性,此自定义属性会覆盖默认属性
|
||||
*/
|
||||
@ -518,6 +525,17 @@ public class MailAccount implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Socket写出超时值,单位毫秒,缺省值不超时
|
||||
*
|
||||
* @param writeTimeout Socket写出超时值,单位毫秒,缺省值不超时
|
||||
* @return this
|
||||
*/
|
||||
public MailAccount setWriteTimeout(final long writeTimeout) {
|
||||
this.writeTimeout = writeTimeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自定义属性列表
|
||||
*
|
||||
@ -563,6 +581,10 @@ public class MailAccount implements Serializable {
|
||||
if (this.connectionTimeout > 0) {
|
||||
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));
|
||||
|
||||
|
@ -37,4 +37,6 @@ splitlongparameters = false
|
||||
# SMTP超时时长,单位毫秒,缺省值不超时
|
||||
timeout = 0
|
||||
# Socket连接超时值,单位毫秒,缺省值不超时
|
||||
connectionTimeout = 0
|
||||
connectionTimeout = 0
|
||||
# Socket写出超时值,单位毫秒,缺省值不超时
|
||||
writeTimeout = 0
|
||||
|
Loading…
Reference in New Issue
Block a user