Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
1cc513d7
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1cc513d7
编写于
3月 29, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consistent to/cc/bcc array handling and revised hashCode without text
Issue: SPR-16671
上级
9a722b45
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
45 deletion
+40
-45
spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java
...main/java/org/springframework/mail/SimpleMailMessage.java
+40
-45
未找到文件。
spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java
浏览文件 @
1cc513d7
/*
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -83,15 +83,9 @@ public class SimpleMailMessage implements MailMessage, Serializable {
...
@@ -83,15 +83,9 @@ public class SimpleMailMessage implements MailMessage, Serializable {
Assert
.
notNull
(
original
,
"'original' message argument must not be null"
);
Assert
.
notNull
(
original
,
"'original' message argument must not be null"
);
this
.
from
=
original
.
getFrom
();
this
.
from
=
original
.
getFrom
();
this
.
replyTo
=
original
.
getReplyTo
();
this
.
replyTo
=
original
.
getReplyTo
();
if
(
original
.
getTo
()
!=
null
)
{
this
.
to
=
copyOrNull
(
original
.
getTo
());
this
.
to
=
copy
(
original
.
getTo
());
this
.
cc
=
copyOrNull
(
original
.
getCc
());
}
this
.
bcc
=
copyOrNull
(
original
.
getBcc
());
if
(
original
.
getCc
()
!=
null
)
{
this
.
cc
=
copy
(
original
.
getCc
());
}
if
(
original
.
getBcc
()
!=
null
)
{
this
.
bcc
=
copy
(
original
.
getBcc
());
}
this
.
sentDate
=
original
.
getSentDate
();
this
.
sentDate
=
original
.
getSentDate
();
this
.
subject
=
original
.
getSubject
();
this
.
subject
=
original
.
getSubject
();
this
.
text
=
original
.
getText
();
this
.
text
=
original
.
getText
();
...
@@ -199,7 +193,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
...
@@ -199,7 +193,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
* @param target the {@code MailMessage} to copy to
* @param target the {@code MailMessage} to copy to
*/
*/
public
void
copyTo
(
MailMessage
target
)
{
public
void
copyTo
(
MailMessage
target
)
{
Assert
.
notNull
(
target
,
"'target'
message argument
must not be null"
);
Assert
.
notNull
(
target
,
"'target'
MailMessage
must not be null"
);
if
(
getFrom
()
!=
null
)
{
if
(
getFrom
()
!=
null
)
{
target
.
setFrom
(
getFrom
());
target
.
setFrom
(
getFrom
());
}
}
...
@@ -207,13 +201,13 @@ public class SimpleMailMessage implements MailMessage, Serializable {
...
@@ -207,13 +201,13 @@ public class SimpleMailMessage implements MailMessage, Serializable {
target
.
setReplyTo
(
getReplyTo
());
target
.
setReplyTo
(
getReplyTo
());
}
}
if
(
getTo
()
!=
null
)
{
if
(
getTo
()
!=
null
)
{
target
.
setTo
(
getTo
(
));
target
.
setTo
(
copy
(
getTo
()
));
}
}
if
(
getCc
()
!=
null
)
{
if
(
getCc
()
!=
null
)
{
target
.
setCc
(
getCc
(
));
target
.
setCc
(
copy
(
getCc
()
));
}
}
if
(
getBcc
()
!=
null
)
{
if
(
getBcc
()
!=
null
)
{
target
.
setBcc
(
getBcc
(
));
target
.
setBcc
(
copy
(
getBcc
()
));
}
}
if
(
getSentDate
()
!=
null
)
{
if
(
getSentDate
()
!=
null
)
{
target
.
setSentDate
(
getSentDate
());
target
.
setSentDate
(
getSentDate
());
...
@@ -227,20 +221,6 @@ public class SimpleMailMessage implements MailMessage, Serializable {
...
@@ -227,20 +221,6 @@ public class SimpleMailMessage implements MailMessage, Serializable {
}
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
(
"SimpleMailMessage: "
);
sb
.
append
(
"from="
).
append
(
this
.
from
).
append
(
"; "
);
sb
.
append
(
"replyTo="
).
append
(
this
.
replyTo
).
append
(
"; "
);
sb
.
append
(
"to="
).
append
(
StringUtils
.
arrayToCommaDelimitedString
(
this
.
to
)).
append
(
"; "
);
sb
.
append
(
"cc="
).
append
(
StringUtils
.
arrayToCommaDelimitedString
(
this
.
cc
)).
append
(
"; "
);
sb
.
append
(
"bcc="
).
append
(
StringUtils
.
arrayToCommaDelimitedString
(
this
.
bcc
)).
append
(
"; "
);
sb
.
append
(
"sentDate="
).
append
(
this
.
sentDate
).
append
(
"; "
);
sb
.
append
(
"subject="
).
append
(
this
.
subject
).
append
(
"; "
);
sb
.
append
(
"text="
).
append
(
this
.
text
);
return
sb
.
toString
();
}
@Override
@Override
public
boolean
equals
(
Object
other
)
{
public
boolean
equals
(
Object
other
)
{
if
(
this
==
other
)
{
if
(
this
==
other
)
{
...
@@ -252,9 +232,9 @@ public class SimpleMailMessage implements MailMessage, Serializable {
...
@@ -252,9 +232,9 @@ public class SimpleMailMessage implements MailMessage, Serializable {
SimpleMailMessage
otherMessage
=
(
SimpleMailMessage
)
other
;
SimpleMailMessage
otherMessage
=
(
SimpleMailMessage
)
other
;
return
(
ObjectUtils
.
nullSafeEquals
(
this
.
from
,
otherMessage
.
from
)
&&
return
(
ObjectUtils
.
nullSafeEquals
(
this
.
from
,
otherMessage
.
from
)
&&
ObjectUtils
.
nullSafeEquals
(
this
.
replyTo
,
otherMessage
.
replyTo
)
&&
ObjectUtils
.
nullSafeEquals
(
this
.
replyTo
,
otherMessage
.
replyTo
)
&&
java
.
util
.
Arrays
.
e
quals
(
this
.
to
,
otherMessage
.
to
)
&&
ObjectUtils
.
nullSafeE
quals
(
this
.
to
,
otherMessage
.
to
)
&&
java
.
util
.
Arrays
.
e
quals
(
this
.
cc
,
otherMessage
.
cc
)
&&
ObjectUtils
.
nullSafeE
quals
(
this
.
cc
,
otherMessage
.
cc
)
&&
java
.
util
.
Arrays
.
e
quals
(
this
.
bcc
,
otherMessage
.
bcc
)
&&
ObjectUtils
.
nullSafeE
quals
(
this
.
bcc
,
otherMessage
.
bcc
)
&&
ObjectUtils
.
nullSafeEquals
(
this
.
sentDate
,
otherMessage
.
sentDate
)
&&
ObjectUtils
.
nullSafeEquals
(
this
.
sentDate
,
otherMessage
.
sentDate
)
&&
ObjectUtils
.
nullSafeEquals
(
this
.
subject
,
otherMessage
.
subject
)
&&
ObjectUtils
.
nullSafeEquals
(
this
.
subject
,
otherMessage
.
subject
)
&&
ObjectUtils
.
nullSafeEquals
(
this
.
text
,
otherMessage
.
text
));
ObjectUtils
.
nullSafeEquals
(
this
.
text
,
otherMessage
.
text
));
...
@@ -262,23 +242,38 @@ public class SimpleMailMessage implements MailMessage, Serializable {
...
@@ -262,23 +242,38 @@ public class SimpleMailMessage implements MailMessage, Serializable {
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
int
hashCode
=
(
this
.
from
==
null
?
0
:
this
.
from
.
hashCode
());
int
hashCode
=
ObjectUtils
.
nullSafeHashCode
(
this
.
from
);
hashCode
=
29
*
hashCode
+
(
this
.
replyTo
==
null
?
0
:
this
.
replyTo
.
hashCode
());
hashCode
=
29
*
hashCode
+
ObjectUtils
.
nullSafeHashCode
(
this
.
replyTo
);
for
(
int
i
=
0
;
this
.
to
!=
null
&&
i
<
this
.
to
.
length
;
i
++)
{
hashCode
=
29
*
hashCode
+
ObjectUtils
.
nullSafeHashCode
(
this
.
to
);
hashCode
=
29
*
hashCode
+
(
this
.
to
==
null
?
0
:
this
.
to
[
i
].
hashCode
());
hashCode
=
29
*
hashCode
+
ObjectUtils
.
nullSafeHashCode
(
this
.
cc
);
}
hashCode
=
29
*
hashCode
+
ObjectUtils
.
nullSafeHashCode
(
this
.
bcc
);
for
(
int
i
=
0
;
this
.
cc
!=
null
&&
i
<
this
.
cc
.
length
;
i
++)
{
hashCode
=
29
*
hashCode
+
ObjectUtils
.
nullSafeHashCode
(
this
.
sentDate
);
hashCode
=
29
*
hashCode
+
(
this
.
cc
==
null
?
0
:
this
.
cc
[
i
].
hashCode
());
hashCode
=
29
*
hashCode
+
ObjectUtils
.
nullSafeHashCode
(
this
.
subject
);
}
for
(
int
i
=
0
;
this
.
bcc
!=
null
&&
i
<
this
.
bcc
.
length
;
i
++)
{
hashCode
=
29
*
hashCode
+
(
this
.
bcc
==
null
?
0
:
this
.
bcc
[
i
].
hashCode
());
}
hashCode
=
29
*
hashCode
+
(
this
.
sentDate
==
null
?
0
:
this
.
sentDate
.
hashCode
());
hashCode
=
29
*
hashCode
+
(
this
.
subject
==
null
?
0
:
this
.
subject
.
hashCode
());
hashCode
=
29
*
hashCode
+
(
this
.
text
==
null
?
0
:
this
.
text
.
hashCode
());
return
hashCode
;
return
hashCode
;
}
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
(
"SimpleMailMessage: "
);
sb
.
append
(
"from="
).
append
(
this
.
from
).
append
(
"; "
);
sb
.
append
(
"replyTo="
).
append
(
this
.
replyTo
).
append
(
"; "
);
sb
.
append
(
"to="
).
append
(
StringUtils
.
arrayToCommaDelimitedString
(
this
.
to
)).
append
(
"; "
);
sb
.
append
(
"cc="
).
append
(
StringUtils
.
arrayToCommaDelimitedString
(
this
.
cc
)).
append
(
"; "
);
sb
.
append
(
"bcc="
).
append
(
StringUtils
.
arrayToCommaDelimitedString
(
this
.
bcc
)).
append
(
"; "
);
sb
.
append
(
"sentDate="
).
append
(
this
.
sentDate
).
append
(
"; "
);
sb
.
append
(
"subject="
).
append
(
this
.
subject
).
append
(
"; "
);
sb
.
append
(
"text="
).
append
(
this
.
text
);
return
sb
.
toString
();
}
@Nullable
private
static
String
[]
copyOrNull
(
@Nullable
String
[]
state
)
{
if
(
state
==
null
)
{
return
null
;
}
return
copy
(
state
);
}
private
static
String
[]
copy
(
String
[]
state
)
{
private
static
String
[]
copy
(
String
[]
state
)
{
String
[]
copy
=
new
String
[
state
.
length
];
String
[]
copy
=
new
String
[
state
.
length
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录