Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
e0883f5e
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 搜索 >>
提交
e0883f5e
编写于
5月 21, 2019
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
59006391
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
57 addition
and
71 deletion
+57
-71
spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java
...java/org/springframework/beans/TypeConverterDelegate.java
+3
-4
spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java
...ory/xml/support/DefaultNamespaceHandlerResolverTests.java
+6
-17
spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java
...java/org/springframework/core/io/ResourceEditorTests.java
+7
-9
spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java
...ork/core/io/support/ResourceArrayPropertyEditorTests.java
+4
-6
spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java
...ingframework/http/converter/FormHttpMessageConverter.java
+2
-2
spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java
...ngframework/web/context/request/async/DeferredResult.java
+10
-10
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java
...work/web/socket/sockjs/support/AbstractSockJsService.java
+25
-23
未找到文件。
spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java
浏览文件 @
e0883f5e
/*
* 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.
...
...
@@ -255,7 +255,7 @@ class TypeConverterDelegate {
}
}
String
trimmedValue
=
((
String
)
convertedValue
).
trim
();
if
(
requiredType
.
isEnum
()
&&
""
.
equals
(
trimmedValue
))
{
if
(
requiredType
.
isEnum
()
&&
trimmedValue
.
isEmpty
(
))
{
// It's an empty enum identifier: reset the enum value to null.
return
null
;
}
...
...
@@ -569,8 +569,7 @@ class TypeConverterDelegate {
return
original
;
}
int
i
=
0
;
for
(;
it
.
hasNext
();
i
++)
{
for
(
int
i
=
0
;
it
.
hasNext
();
i
++)
{
Object
element
=
it
.
next
();
String
indexedPropertyName
=
buildIndexedPropertyName
(
propertyName
,
i
);
Object
convertedElement
=
convertIfNecessary
(
indexedPropertyName
,
null
,
element
,
...
...
spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java
浏览文件 @
e0883f5e
/*
* Copyright 2002-201
2
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.
...
...
@@ -49,7 +49,7 @@ public class DefaultNamespaceHandlerResolverTests {
}
@Test
public
void
testNonExistentHandlerClass
()
throws
Exception
{
public
void
testNonExistentHandlerClass
()
{
String
mappingPath
=
"org/springframework/beans/factory/xml/support/nonExistent.properties"
;
try
{
new
DefaultNamespaceHandlerResolver
(
getClass
().
getClassLoader
(),
mappingPath
);
...
...
@@ -61,29 +61,18 @@ public class DefaultNamespaceHandlerResolverTests {
}
@Test
public
void
testResolveInvalidHandler
()
throws
Exception
{
String
mappingPath
=
"org/springframework/beans/factory/xml/support/invalid.properties"
;
try
{
new
DefaultNamespaceHandlerResolver
(
getClass
().
getClassLoader
(),
mappingPath
);
fail
(
"Should not be able to map a class that doesn't implement NamespaceHandler"
);
}
catch
(
Throwable
expected
)
{
}
}
@Test
public
void
testCtorWithNullClassLoaderArgument
()
throws
Exception
{
public
void
testCtorWithNullClassLoaderArgument
()
{
// simply must not bail...
new
DefaultNamespaceHandlerResolver
(
null
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument
()
throws
Exception
{
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testCtorWithNullClassLoaderArgumentAndNullMappingLocationArgument
()
{
new
DefaultNamespaceHandlerResolver
(
null
,
null
);
}
@Test
public
void
testCtorWithNonExistentMappingLocationArgument
()
throws
Exception
{
public
void
testCtorWithNonExistentMappingLocationArgument
()
{
// simply must not bail; we don't want non-existent resources to result in an Exception
new
DefaultNamespaceHandlerResolver
(
null
,
"738trbc bobabloobop871"
);
}
...
...
spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java
浏览文件 @
e0883f5e
/*
* Copyright 2002-201
0
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.
...
...
@@ -31,10 +31,10 @@ import static org.junit.Assert.*;
* @author Arjen Poutsma
* @author Dave Syer
*/
public
final
class
ResourceEditorTests
{
public
class
ResourceEditorTests
{
@Test
public
void
sunnyDay
()
throws
Exception
{
public
void
sunnyDay
()
{
PropertyEditor
editor
=
new
ResourceEditor
();
editor
.
setAsText
(
"classpath:org/springframework/core/io/ResourceEditorTests.class"
);
Resource
resource
=
(
Resource
)
editor
.
getValue
();
...
...
@@ -43,19 +43,19 @@ public final class ResourceEditorTests {
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
ctorWithNullCtorArgs
()
throws
Exception
{
public
void
ctorWithNullCtorArgs
()
{
new
ResourceEditor
(
null
,
null
);
}
@Test
public
void
setAndGetAsTextWithNull
()
throws
Exception
{
public
void
setAndGetAsTextWithNull
()
{
PropertyEditor
editor
=
new
ResourceEditor
();
editor
.
setAsText
(
null
);
assertEquals
(
""
,
editor
.
getAsText
());
}
@Test
public
void
setAndGetAsTextWithWhitespaceResource
()
throws
Exception
{
public
void
setAndGetAsTextWithWhitespaceResource
()
{
PropertyEditor
editor
=
new
ResourceEditor
();
editor
.
setAsText
(
" "
);
assertEquals
(
""
,
editor
.
getAsText
());
...
...
@@ -75,14 +75,12 @@ public final class ResourceEditorTests {
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testStrictSystemPropertyReplacement
()
{
PropertyEditor
editor
=
new
ResourceEditor
(
new
DefaultResourceLoader
(),
new
StandardEnvironment
(),
false
);
System
.
setProperty
(
"test.prop"
,
"foo"
);
try
{
editor
.
setAsText
(
"${test.prop}-${bar}"
);
Resource
resolved
=
(
Resource
)
editor
.
getValue
();
assertEquals
(
"foo-${bar}"
,
resolved
.
getFilename
());
}
finally
{
System
.
getProperties
().
remove
(
"test.prop"
);
...
...
spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java
浏览文件 @
e0883f5e
/*
* Copyright 2002-201
2
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.
...
...
@@ -32,7 +32,7 @@ import static org.junit.Assert.*;
public
class
ResourceArrayPropertyEditorTests
{
@Test
public
void
testVanillaResource
()
throws
Exception
{
public
void
testVanillaResource
()
{
PropertyEditor
editor
=
new
ResourceArrayPropertyEditor
();
editor
.
setAsText
(
"classpath:org/springframework/core/io/support/ResourceArrayPropertyEditor.class"
);
Resource
[]
resources
=
(
Resource
[])
editor
.
getValue
();
...
...
@@ -41,7 +41,7 @@ public class ResourceArrayPropertyEditorTests {
}
@Test
public
void
testPatternResource
()
throws
Exception
{
public
void
testPatternResource
()
{
// N.B. this will sometimes fail if you use classpath: instead of classpath*:.
// The result depends on the classpath - if test-classes are segregated from classes
// and they come first on the classpath (like in Maven) then it breaks, if classes
...
...
@@ -67,7 +67,7 @@ public class ResourceArrayPropertyEditorTests {
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testStrictSystemPropertyReplacement
()
{
PropertyEditor
editor
=
new
ResourceArrayPropertyEditor
(
new
PathMatchingResourcePatternResolver
(),
new
StandardEnvironment
(),
...
...
@@ -75,8 +75,6 @@ public class ResourceArrayPropertyEditorTests {
System
.
setProperty
(
"test.prop"
,
"foo"
);
try
{
editor
.
setAsText
(
"${test.prop}-${bar}"
);
Resource
[]
resources
=
(
Resource
[])
editor
.
getValue
();
assertEquals
(
"foo-${bar}"
,
resources
[
0
].
getFilename
());
}
finally
{
System
.
getProperties
().
remove
(
"test.prop"
);
...
...
spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java
浏览文件 @
e0883f5e
...
...
@@ -266,8 +266,8 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
if
(
contentType
!=
null
)
{
return
MediaType
.
MULTIPART_FORM_DATA
.
includes
(
contentType
);
}
for
(
String
name
:
map
.
keySet
())
{
for
(
Object
value
:
map
.
get
(
name
)
)
{
for
(
List
<?>
values
:
map
.
values
())
{
for
(
Object
value
:
values
)
{
if
(
value
!=
null
&&
!(
value
instanceof
String
))
{
return
true
;
}
...
...
spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java
浏览文件 @
e0883f5e
/*
* Copyright 2002-201
6
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.
...
...
@@ -54,7 +54,7 @@ public class DeferredResult<T> {
private
static
final
Log
logger
=
LogFactory
.
getLog
(
DeferredResult
.
class
);
private
final
Long
timeout
;
private
final
Long
timeout
Value
;
private
final
Object
timeoutResult
;
...
...
@@ -77,25 +77,25 @@ public class DeferredResult<T> {
}
/**
* Create a DeferredResult with a timeout value.
* Create a DeferredResult with a
custom
timeout value.
* <p>By default not set in which case the default configured in the MVC
* Java Config or the MVC namespace is used, or if that's not set, then the
* timeout depends on the default of the underlying server.
* @param timeout timeout value in milliseconds
* @param timeout
Value
timeout value in milliseconds
*/
public
DeferredResult
(
Long
timeout
)
{
this
(
timeout
,
RESULT_NONE
);
public
DeferredResult
(
Long
timeout
Value
)
{
this
(
timeout
Value
,
RESULT_NONE
);
}
/**
* Create a DeferredResult with a timeout value and a default result to use
* in case of timeout.
* @param timeout timeout value in milliseconds (ignored if {@code null})
* @param timeout
Value
timeout value in milliseconds (ignored if {@code null})
* @param timeoutResult the result to use
*/
public
DeferredResult
(
Long
timeout
,
Object
timeoutResult
)
{
public
DeferredResult
(
Long
timeoutValue
,
Object
timeoutResult
)
{
this
.
timeoutValue
=
timeoutValue
;
this
.
timeoutResult
=
timeoutResult
;
this
.
timeout
=
timeout
;
}
...
...
@@ -134,7 +134,7 @@ public class DeferredResult<T> {
* Return the configured timeout value in milliseconds.
*/
final
Long
getTimeoutValue
()
{
return
this
.
timeout
;
return
this
.
timeout
Value
;
}
/**
...
...
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java
浏览文件 @
e0883f5e
/*
* 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.
...
...
@@ -67,14 +67,14 @@ import org.springframework.web.util.WebUtils;
*/
public
abstract
class
AbstractSockJsService
implements
SockJsService
,
CorsConfigurationSource
{
private
static
final
Charset
UTF8_CHARSET
=
Charset
.
forName
(
"UTF-8"
)
;
private
static
final
String
XFRAME_OPTIONS_HEADER
=
"X-Frame-Options"
;
private
static
final
long
ONE_YEAR
=
TimeUnit
.
DAYS
.
toSeconds
(
365
);
private
static
final
Random
random
=
new
Random
(
);
private
static
final
Charset
UTF8_CHARSET
=
Charset
.
forName
(
"UTF-8"
);
private
static
final
String
XFRAME_OPTIONS_HEADER
=
"X-Frame-Options"
;
private
static
final
Random
random
=
new
Random
();
protected
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
...
...
@@ -88,9 +88,9 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
private
boolean
sessionCookieNeeded
=
true
;
private
long
heartbeatTime
=
25
*
1000
;
private
long
heartbeatTime
=
TimeUnit
.
SECONDS
.
toMillis
(
25
)
;
private
long
disconnectDelay
=
5
*
1000
;
private
long
disconnectDelay
=
TimeUnit
.
SECONDS
.
toMillis
(
5
)
;
private
int
httpMessageCacheSize
=
100
;
...
...
@@ -287,8 +287,9 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
}
/**
* Return if automatic addition of CORS headers has been disabled.
* @since 4.1.2
* @see #setSuppressCors
(boolean)
* @see #setSuppressCors
*/
public
boolean
shouldSuppressCors
()
{
return
this
.
suppressCors
;
...
...
@@ -316,6 +317,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
}
/**
* Return configure allowed {@code Origin} header values.
* @since 4.1.2
* @see #setAllowedOrigins
*/
...
...
@@ -350,7 +352,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
String
requestInfo
=
(
logger
.
isDebugEnabled
()
?
request
.
getMethod
()
+
" "
+
request
.
getURI
()
:
null
);
try
{
if
(
sockJsPath
.
equals
(
""
)
||
sockJsPath
.
equals
(
"/"
))
{
if
(
sockJsPath
.
isEmpty
(
)
||
sockJsPath
.
equals
(
"/"
))
{
if
(
requestInfo
!=
null
)
{
logger
.
debug
(
"Processing transport request: "
+
requestInfo
);
}
...
...
@@ -571,21 +573,21 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig
private
static
final
String
IFRAME_CONTENT
=
"<!DOCTYPE html>\n"
+
"<html>\n"
+
"<head>\n"
+
" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n"
+
" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
+
" <script>\n"
+
" document.domain = document.domain;\n"
+
" _sockjs_onload = function(){SockJS.bootstrap_iframe();};\n"
+
" </script>\n"
+
" <script src=\"%s\"></script>\n"
+
"</head>\n"
+
"<body>\n"
+
" <h2>Don't panic!</h2>\n"
+
" <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>\n"
+
"</body>\n"
+
"</html>"
;
"<html>\n"
+
"<head>\n"
+
" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n"
+
" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
+
" <script>\n"
+
" document.domain = document.domain;\n"
+
" _sockjs_onload = function(){SockJS.bootstrap_iframe();};\n"
+
" </script>\n"
+
" <script src=\"%s\"></script>\n"
+
"</head>\n"
+
"<body>\n"
+
" <h2>Don't panic!</h2>\n"
+
" <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>\n"
+
"</body>\n"
+
"</html>"
;
@Override
public
void
handle
(
ServerHttpRequest
request
,
ServerHttpResponse
response
)
throws
IOException
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录