Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
191a2d3f
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,发现更多精彩内容 >>
提交
191a2d3f
编写于
12月 03, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
JavaMailSenderImpl calls sendMessage with empty array instead of null
Issue: SPR-17540 (cherry picked from commit
16e9b83d
)
上级
a46a4372
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
22 addition
and
16 deletion
+22
-16
spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java
...org/springframework/mail/javamail/JavaMailSenderImpl.java
+5
-3
spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java
...rg/springframework/mail/javamail/JavaMailSenderTests.java
+17
-13
未找到文件。
spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java
浏览文件 @
191a2d3f
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -24,6 +24,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Properties
;
import
javax.activation.FileTypeMap
;
import
javax.mail.Address
;
import
javax.mail.AuthenticationFailedException
;
import
javax.mail.MessagingException
;
import
javax.mail.NoSuchProviderException
;
...
...
@@ -390,7 +391,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
/**
* Actually send the given array of MimeMessages via JavaMail.
* @param mimeMessages MimeMessage objects to send
* @param mimeMessages
the
MimeMessage objects to send
* @param originalMessages corresponding original message objects
* that the MimeMessages have been created from (with same array
* length and indices as the "mimeMessages" array), if any
...
...
@@ -445,7 +446,8 @@ public class JavaMailSenderImpl implements JavaMailSender {
// Preserve explicitly specified message id...
mimeMessage
.
setHeader
(
HEADER_MESSAGE_ID
,
messageId
);
}
transport
.
sendMessage
(
mimeMessage
,
mimeMessage
.
getAllRecipients
());
Address
[]
addresses
=
mimeMessage
.
getAllRecipients
();
transport
.
sendMessage
(
mimeMessage
,
(
addresses
!=
null
?
addresses
:
new
Address
[
0
]));
}
catch
(
Exception
ex
)
{
Object
original
=
(
originalMessages
!=
null
?
originalMessages
[
i
]
:
mimeMessage
);
...
...
spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java
浏览文件 @
191a2d3f
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
8
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -56,6 +56,7 @@ public class JavaMailSenderTests {
@Rule
public
final
ExpectedException
thrown
=
ExpectedException
.
none
();
@Test
public
void
javaMailSenderWithSimpleMessage
()
throws
MessagingException
,
IOException
{
MockJavaMailSender
sender
=
new
MockJavaMailSender
();
...
...
@@ -105,7 +106,8 @@ public class JavaMailSenderTests {
assertEquals
(
"my text"
,
sentMessage
.
getContent
());
}
public
void
testJavaMailSenderWithSimpleMessages
()
throws
MessagingException
,
IOException
{
@Test
public
void
javaMailSenderWithSimpleMessages
()
throws
MessagingException
{
MockJavaMailSender
sender
=
new
MockJavaMailSender
();
sender
.
setHost
(
"host"
);
sender
.
setUsername
(
"username"
);
...
...
@@ -133,7 +135,8 @@ public class JavaMailSenderTests {
assertEquals
(
"she@mail.org"
,
((
InternetAddress
)
tos2
.
get
(
0
)).
getAddress
());
}
public
void
testJavaMailSenderWithMimeMessage
()
throws
MessagingException
{
@Test
public
void
javaMailSenderWithMimeMessage
()
throws
MessagingException
{
MockJavaMailSender
sender
=
new
MockJavaMailSender
();
sender
.
setHost
(
"host"
);
sender
.
setUsername
(
"username"
);
...
...
@@ -180,7 +183,7 @@ public class JavaMailSenderTests {
sender
.
setUsername
(
"username"
);
sender
.
setPassword
(
"password"
);
final
List
<
Message
>
messages
=
new
ArrayList
<
Message
>();
final
List
<
Message
>
messages
=
new
ArrayList
<>();
MimeMessagePreparator
preparator
=
new
MimeMessagePreparator
()
{
@Override
...
...
@@ -206,7 +209,7 @@ public class JavaMailSenderTests {
sender
.
setUsername
(
"username"
);
sender
.
setPassword
(
"password"
);
final
List
<
Message
>
messages
=
new
ArrayList
<
Message
>();
final
List
<
Message
>
messages
=
new
ArrayList
<>();
MimeMessagePreparator
preparator1
=
new
MimeMessagePreparator
()
{
@Override
...
...
@@ -394,7 +397,7 @@ public class JavaMailSenderTests {
}
@Test
public
void
failedMailServerConnect
()
throws
Exception
{
public
void
failedMailServerConnect
()
{
MockJavaMailSender
sender
=
new
MockJavaMailSender
();
sender
.
setHost
(
null
);
sender
.
setUsername
(
"username"
);
...
...
@@ -415,7 +418,7 @@ public class JavaMailSenderTests {
}
@Test
public
void
failedMailServerClose
()
throws
Exception
{
public
void
failedMailServerClose
()
{
MockJavaMailSender
sender
=
new
MockJavaMailSender
();
sender
.
setHost
(
""
);
sender
.
setUsername
(
"username"
);
...
...
@@ -434,7 +437,7 @@ public class JavaMailSenderTests {
}
@Test
public
void
failedSimpleMessage
()
throws
Exception
{
public
void
failedSimpleMessage
()
throws
Messaging
Exception
{
MockJavaMailSender
sender
=
new
MockJavaMailSender
();
sender
.
setHost
(
"host"
);
sender
.
setUsername
(
"username"
);
...
...
@@ -466,7 +469,7 @@ public class JavaMailSenderTests {
}
@Test
public
void
f
FailedMimeMessage
()
throws
Exception
{
public
void
f
ailedMimeMessage
()
throws
Messaging
Exception
{
MockJavaMailSender
sender
=
new
MockJavaMailSender
();
sender
.
setHost
(
"host"
);
sender
.
setUsername
(
"username"
);
...
...
@@ -498,14 +501,14 @@ public class JavaMailSenderTests {
}
@Test
public
void
testConnection
()
throws
Exception
{
public
void
testConnection
()
throws
Messaging
Exception
{
MockJavaMailSender
sender
=
new
MockJavaMailSender
();
sender
.
setHost
(
"host"
);
sender
.
testConnection
();
}
@Test
public
void
testConnectionWithFailure
()
throws
Exception
{
public
void
testConnectionWithFailure
()
throws
Messaging
Exception
{
MockJavaMailSender
sender
=
new
MockJavaMailSender
();
sender
.
setHost
(
null
);
...
...
@@ -533,7 +536,7 @@ public class JavaMailSenderTests {
private
String
connectedUsername
=
null
;
private
String
connectedPassword
=
null
;
private
boolean
closeCalled
=
false
;
private
List
<
Message
>
sentMessages
=
new
ArrayList
<
Message
>();
private
List
<
Message
>
sentMessages
=
new
ArrayList
<>();
private
MockTransport
(
Session
session
,
URLName
urlName
)
{
super
(
session
,
urlName
);
...
...
@@ -592,7 +595,8 @@ public class JavaMailSenderTests {
if
(
"fail"
.
equals
(
message
.
getSubject
()))
{
throw
new
MessagingException
(
"failed"
);
}
if
(!
ObjectUtils
.
nullSafeEquals
(
addresses
,
message
.
getAllRecipients
()))
{
if
(
addresses
==
null
||
(
message
.
getAllRecipients
()
==
null
?
addresses
.
length
>
0
:
!
ObjectUtils
.
nullSafeEquals
(
addresses
,
message
.
getAllRecipients
())))
{
throw
new
MessagingException
(
"addresses not correct"
);
}
if
(
message
.
getSentDate
()
==
null
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录