Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
5b1b1bae
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,体验更适合开发者的 AI 搜索 >>
提交
5b1b1bae
编写于
5月 03, 2019
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consistent use of try-with-resources for local resource closing
上级
31c3b8a2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
19 deletion
+22
-19
spring-core/src/main/java/org/springframework/util/SerializationUtils.java
...ain/java/org/springframework/util/SerializationUtils.java
+3
-5
spring-core/src/test/java/org/springframework/util/SerializationTestUtils.java
...java/org/springframework/util/SerializationTestUtils.java
+11
-9
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java
...tasource/embedded/AbstractEmbeddedDatabaseConfigurer.java
+5
-2
spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java
.../main/java/org/springframework/http/MediaTypeFactory.java
+3
-3
未找到文件。
spring-core/src/main/java/org/springframework/util/SerializationUtils.java
浏览文件 @
5b1b1bae
/*
* Copyright 2002-201
7
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -43,8 +43,7 @@ public abstract class SerializationUtils {
return
null
;
}
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
(
1024
);
try
{
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
baos
);
try
(
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
baos
))
{
oos
.
writeObject
(
object
);
oos
.
flush
();
}
...
...
@@ -64,8 +63,7 @@ public abstract class SerializationUtils {
if
(
bytes
==
null
)
{
return
null
;
}
try
{
ObjectInputStream
ois
=
new
ObjectInputStream
(
new
ByteArrayInputStream
(
bytes
));
try
(
ObjectInputStream
ois
=
new
ObjectInputStream
(
new
ByteArrayInputStream
(
bytes
)))
{
return
ois
.
readObject
();
}
catch
(
IOException
ex
)
{
...
...
spring-core/src/test/java/org/springframework/util/SerializationTestUtils.java
浏览文件 @
5b1b1bae
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -34,8 +34,9 @@ public class SerializationTestUtils {
public
static
void
testSerialization
(
Object
o
)
throws
IOException
{
OutputStream
baos
=
new
ByteArrayOutputStream
();
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
baos
);
oos
.
writeObject
(
o
);
try
(
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
baos
))
{
oos
.
writeObject
(
o
);
}
}
public
static
boolean
isSerializable
(
Object
o
)
throws
IOException
{
...
...
@@ -50,16 +51,17 @@ public class SerializationTestUtils {
public
static
Object
serializeAndDeserialize
(
Object
o
)
throws
IOException
,
ClassNotFoundException
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
baos
);
oos
.
writeObject
(
o
);
oos
.
flush
();
try
(
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
baos
))
{
oos
.
writeObject
(
o
);
oos
.
flush
();
}
baos
.
flush
();
byte
[]
bytes
=
baos
.
toByteArray
();
ByteArrayInputStream
is
=
new
ByteArrayInputStream
(
bytes
);
ObjectInputStream
ois
=
new
ObjectInputStream
(
is
);
Object
o2
=
ois
.
readObject
();
return
o2
;
try
(
ObjectInputStream
ois
=
new
ObjectInputStream
(
is
))
{
return
ois
.
readObject
();
}
}
}
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java
浏览文件 @
5b1b1bae
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -18,6 +18,7 @@ package org.springframework.jdbc.datasource.embedded;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
javax.sql.DataSource
;
import
org.apache.commons.logging.Log
;
...
...
@@ -42,7 +43,9 @@ abstract class AbstractEmbeddedDatabaseConfigurer implements EmbeddedDatabaseCon
try
{
con
=
dataSource
.
getConnection
();
if
(
con
!=
null
)
{
con
.
createStatement
().
execute
(
"SHUTDOWN"
);
try
(
Statement
stmt
=
con
.
createStatement
())
{
stmt
.
execute
(
"SHUTDOWN"
);
}
}
}
catch
(
SQLException
ex
)
{
...
...
spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java
浏览文件 @
5b1b1bae
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -64,8 +64,8 @@ public final class MediaTypeFactory {
* @return a multi-value map, mapping media types to file extensions.
*/
private
static
MultiValueMap
<
String
,
MediaType
>
parseMimeTypes
()
{
try
(
InputStream
is
=
MediaTypeFactory
.
class
.
getResourceAsStream
(
MIME_TYPES_FILE_NAME
))
{
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
is
,
StandardCharsets
.
US_ASCII
));
InputStream
is
=
MediaTypeFactory
.
class
.
getResourceAsStream
(
MIME_TYPES_FILE_NAME
);
try
(
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
is
,
StandardCharsets
.
US_ASCII
)))
{
MultiValueMap
<
String
,
MediaType
>
result
=
new
LinkedMultiValueMap
<>();
String
line
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录