Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
带水的鱼儿
spring-framework
提交
0b76b13d
S
spring-framework
项目概览
带水的鱼儿
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
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,发现更多精彩内容 >>
提交
0b76b13d
编写于
12月 01, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
(cherry picked from commit
5fee5f39
)
上级
23e91e1a
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
220 addition
and
217 deletion
+220
-217
spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java
.../main/java/org/springframework/beans/PropertyMatches.java
+18
-17
spring-context/src/main/java/org/springframework/context/support/ConversionServiceFactoryBean.java
...amework/context/support/ConversionServiceFactoryBean.java
+6
-6
spring-context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java
...ringframework/jmx/support/ConnectorServerFactoryBean.java
+1
-2
spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java
...amework/scripting/support/ScriptFactoryPostProcessor.java
+4
-4
spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java
...ework/cache/config/ExpressionCachingIntegrationTests.java
+21
-9
spring-core/src/main/java/org/springframework/core/convert/Property.java
.../main/java/org/springframework/core/convert/Property.java
+2
-2
spring-core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java
...springframework/core/convert/support/ConversionUtils.java
+6
-3
spring-core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java
...mework/core/convert/support/DefaultConversionService.java
+1
-2
spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
...mework/core/convert/support/GenericConversionService.java
+2
-2
spring-expression/src/main/java/org/springframework/expression/EvaluationException.java
...a/org/springframework/expression/EvaluationException.java
+21
-16
spring-expression/src/main/java/org/springframework/expression/ExpressionException.java
...a/org/springframework/expression/ExpressionException.java
+26
-23
spring-expression/src/main/java/org/springframework/expression/ParseException.java
...n/java/org/springframework/expression/ParseException.java
+4
-4
spring-expression/src/main/java/org/springframework/expression/spel/SpelEvaluationException.java
...ingframework/expression/spel/SpelEvaluationException.java
+16
-26
spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java
...java/org/springframework/expression/spel/SpelMessage.java
+8
-10
spring-expression/src/main/java/org/springframework/expression/spel/SpelParseException.java
...g/springframework/expression/spel/SpelParseException.java
+12
-15
spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpRequestFactory.java
...framework/http/client/SimpleClientHttpRequestFactory.java
+2
-3
spring-web/src/main/java/org/springframework/web/util/UriTemplate.java
...c/main/java/org/springframework/web/util/UriTemplate.java
+7
-9
spring-web/src/test/java/org/springframework/web/client/AbstractJettyServerTestCase.java
...ringframework/web/client/AbstractJettyServerTestCase.java
+35
-35
spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java
...amework/web/client/AsyncRestTemplateIntegrationTests.java
+0
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/ResourceServlet.java
...java/org/springframework/web/servlet/ResourceServlet.java
+21
-19
spring-websocket/src/main/java/org/springframework/web/socket/WebSocketMessage.java
...java/org/springframework/web/socket/WebSocketMessage.java
+2
-3
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java
...ocket/sockjs/transport/session/AbstractSockJsSession.java
+5
-5
未找到文件。
spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -30,8 +30,8 @@ import org.springframework.util.StringUtils;
* Helper class for calculating property matches, according to a configurable
* distance. Provide the list of potential matches and an easy way to generate
* an error message. Works for both java bean properties and fields.
*
<p>
*
Mainly for use within the framework and in particular the binding facility
*
*
<p>Mainly for use within the framework and in particular the binding facility.
*
* @author Alef Arendsen
* @author Arjen Poutsma
...
...
@@ -43,14 +43,12 @@ import org.springframework.util.StringUtils;
*/
public
abstract
class
PropertyMatches
{
//---------------------------------------------------------------------
// Static section
//---------------------------------------------------------------------
/** Default maximum property distance: 2 */
public
static
final
int
DEFAULT_MAX_DISTANCE
=
2
;
// Static factory methods
/**
* Create PropertyMatches for the given bean property.
* @param propertyName the name of the property to find possible matches for
...
...
@@ -90,9 +88,7 @@ public abstract class PropertyMatches {
}
//---------------------------------------------------------------------
// Instance section
//---------------------------------------------------------------------
// Instance state
private
final
String
propertyName
;
...
...
@@ -107,18 +103,19 @@ public abstract class PropertyMatches {
this
.
possibleMatches
=
possibleMatches
;
}
/**
* Return the name of the requested property.
*/
public
String
getPropertyName
()
{
return
propertyName
;
return
this
.
propertyName
;
}
/**
* Return the calculated possible matches.
*/
public
String
[]
getPossibleMatches
()
{
return
possibleMatches
;
return
this
.
possibleMatches
;
}
/**
...
...
@@ -127,6 +124,9 @@ public abstract class PropertyMatches {
*/
public
abstract
String
buildErrorMessage
();
// Implementation support for subclasses
protected
void
appendHintMessage
(
StringBuilder
msg
)
{
msg
.
append
(
"Did you mean "
);
for
(
int
i
=
0
;
i
<
this
.
possibleMatches
.
length
;
i
++)
{
...
...
@@ -184,9 +184,12 @@ public abstract class PropertyMatches {
return
d
[
s1
.
length
()][
s2
.
length
()];
}
// Concrete subclasses
private
static
class
BeanPropertyMatches
extends
PropertyMatches
{
p
rivate
BeanPropertyMatches
(
String
propertyName
,
Class
<?>
beanClass
,
int
maxDistance
)
{
p
ublic
BeanPropertyMatches
(
String
propertyName
,
Class
<?>
beanClass
,
int
maxDistance
)
{
super
(
propertyName
,
calculateMatches
(
propertyName
,
BeanUtils
.
getPropertyDescriptors
(
beanClass
),
maxDistance
));
}
...
...
@@ -231,12 +234,12 @@ public abstract class PropertyMatches {
}
return
msg
.
toString
();
}
}
private
static
class
FieldPropertyMatches
extends
PropertyMatches
{
p
rivate
FieldPropertyMatches
(
String
propertyName
,
Class
<?>
beanClass
,
int
maxDistance
)
{
p
ublic
FieldPropertyMatches
(
String
propertyName
,
Class
<?>
beanClass
,
int
maxDistance
)
{
super
(
propertyName
,
calculateMatches
(
propertyName
,
beanClass
,
maxDistance
));
}
...
...
@@ -255,7 +258,6 @@ public abstract class PropertyMatches {
return
StringUtils
.
toStringArray
(
candidates
);
}
@Override
public
String
buildErrorMessage
()
{
String
propertyName
=
getPropertyName
();
...
...
@@ -270,7 +272,6 @@ public abstract class PropertyMatches {
}
return
msg
.
toString
();
}
}
}
spring-context/src/main/java/org/springframework/context/support/ConversionServiceFactoryBean.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -27,12 +27,12 @@ import org.springframework.core.convert.support.GenericConversionService;
/**
* A factory providing convenient access to a ConversionService configured with
* converters appropriate for most environments. Set the
{@link #setConverters
* "converters"} property to supplement the default converters.
* converters appropriate for most environments. Set the
*
{@link #setConverters
"converters"} property to supplement the default converters.
*
* <p>This implementation creates a {@link DefaultConversionService}.
Subclasses
*
may override {@link #createConversionService()} in order to return a
* {@link GenericConversionService} instance of their choosing.
* <p>This implementation creates a {@link DefaultConversionService}.
*
Subclasses may override {@link #createConversionService()} in order to return
*
a
{@link GenericConversionService} instance of their choosing.
*
* <p>Like all {@code FactoryBean} implementations, this class is suitable for
* use when configuring a Spring application context using Spring {@code <beans>}
...
...
spring-context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
6
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,6 @@ import org.springframework.util.CollectionUtils;
* @author Rob Harrop
* @author Juergen Hoeller
* @since 1.2
* @see FactoryBean
* @see JMXConnectorServer
* @see MBeanServer
*/
...
...
spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -206,8 +206,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
@Override
public
void
setBeanFactory
(
BeanFactory
beanFactory
)
{
if
(!(
beanFactory
instanceof
ConfigurableBeanFactory
))
{
throw
new
IllegalStateException
(
"ScriptFactoryPostProcessor doesn't work with
a BeanFactory "
+
"which does not implement
ConfigurableBeanFactory: "
+
beanFactory
.
getClass
());
throw
new
IllegalStateException
(
"ScriptFactoryPostProcessor doesn't work with
"
+
"non-
ConfigurableBeanFactory: "
+
beanFactory
.
getClass
());
}
this
.
beanFactory
=
(
ConfigurableBeanFactory
)
beanFactory
;
...
...
@@ -381,7 +381,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
* If the {@link BeanDefinition} has a
* {@link org.springframework.core.AttributeAccessor metadata attribute}
* under the key {@link #REFRESH_CHECK_DELAY_ATTRIBUTE} which is a valid {@link Number}
* type, then this value is used. Otherwise, the
the
{@link #defaultRefreshCheckDelay}
* type, then this value is used. Otherwise, the {@link #defaultRefreshCheckDelay}
* value is used.
* @param beanDefinition the BeanDefinition to check
* @return the refresh check delay
...
...
spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -29,13 +29,12 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
/**
*
* @author Stephane Nicoll
*/
public
class
ExpressionCachingIntegrationTests
{
@Test
// SPR-11692
@SuppressWarnings
(
"unchecked"
)
@Test
// SPR-11692
public
void
expressionIsCacheBasedOnActualMethod
()
{
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
(
SharedConfig
.
class
,
Spr11692Config
.
class
);
...
...
@@ -50,9 +49,9 @@ public class ExpressionCachingIntegrationTests {
}
@Configuration
static
class
Spr11692Config
{
@Bean
public
BaseDao
<
User
>
userDao
()
{
return
new
UserDaoImpl
();
...
...
@@ -65,11 +64,14 @@ public class ExpressionCachingIntegrationTests {
}
private
static
interface
BaseDao
<
T
>
{
private
interface
BaseDao
<
T
>
{
T
persist
(
T
t
);
}
private
static
class
UserDaoImpl
implements
BaseDao
<
User
>
{
@Override
@CachePut
(
value
=
"users"
,
key
=
"#user.id"
)
public
User
persist
(
User
user
)
{
...
...
@@ -77,7 +79,9 @@ public class ExpressionCachingIntegrationTests {
}
}
private
static
class
OrderDaoImpl
implements
BaseDao
<
Order
>
{
@Override
@CachePut
(
value
=
"orders"
,
key
=
"#order.id"
)
public
Order
persist
(
Order
order
)
{
...
...
@@ -85,33 +89,41 @@ public class ExpressionCachingIntegrationTests {
}
}
private
static
class
User
{
private
final
String
id
;
p
rivate
User
(
String
id
)
{
p
ublic
User
(
String
id
)
{
this
.
id
=
id
;
}
@SuppressWarnings
(
"unused"
)
public
String
getId
()
{
return
id
;
return
this
.
id
;
}
}
private
static
class
Order
{
private
final
String
id
;
p
rivate
Order
(
String
id
)
{
p
ublic
Order
(
String
id
)
{
this
.
id
=
id
;
}
@SuppressWarnings
(
"unused"
)
public
String
getId
()
{
return
id
;
return
this
.
id
;
}
}
@Configuration
@EnableCaching
static
class
SharedConfig
extends
CachingConfigurerSupport
{
@Override
@Bean
public
CacheManager
cacheManager
()
{
...
...
spring-core/src/main/java/org/springframework/core/convert/Property.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -72,7 +72,7 @@ public final class Property {
this
.
readMethod
=
readMethod
;
this
.
writeMethod
=
writeMethod
;
this
.
methodParameter
=
resolveMethodParameter
();
this
.
name
=
(
name
==
null
?
resolveName
()
:
name
);
this
.
name
=
(
name
!=
null
?
name
:
resolveName
()
);
}
...
...
spring-core/src/main/java/org/springframework/core/convert/support/ConversionUtils.java
浏览文件 @
0b76b13d
...
...
@@ -31,6 +31,7 @@ abstract class ConversionUtils {
public
static
Object
invokeConverter
(
GenericConverter
converter
,
Object
source
,
TypeDescriptor
sourceType
,
TypeDescriptor
targetType
)
{
try
{
return
converter
.
convert
(
source
,
sourceType
,
targetType
);
}
...
...
@@ -42,7 +43,9 @@ abstract class ConversionUtils {
}
}
public
static
boolean
canConvertElements
(
TypeDescriptor
sourceElementType
,
TypeDescriptor
targetElementType
,
ConversionService
conversionService
)
{
public
static
boolean
canConvertElements
(
TypeDescriptor
sourceElementType
,
TypeDescriptor
targetElementType
,
ConversionService
conversionService
)
{
if
(
targetElementType
==
null
)
{
// yes
return
true
;
...
...
@@ -56,11 +59,11 @@ abstract class ConversionUtils {
return
true
;
}
else
if
(
sourceElementType
.
getType
().
isAssignableFrom
(
targetElementType
.
getType
()))
{
// maybe
;
// maybe
return
true
;
}
else
{
// no
;
// no
return
false
;
}
}
...
...
spring-core/src/main/java/org/springframework/core/convert/support/DefaultConversionService.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -53,7 +53,6 @@ public class DefaultConversionService extends GenericConversionService {
"java.util.stream.Stream"
,
DefaultConversionService
.
class
.
getClassLoader
());
/**
* Create a new {@code DefaultConversionService} with the set of
* {@linkplain DefaultConversionService#addDefaultConverters(ConverterRegistry) default converters}.
...
...
spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
浏览文件 @
0b76b13d
...
...
@@ -66,8 +66,8 @@ public class GenericConversionService implements ConfigurableConversionService {
private
static
final
GenericConverter
NO_OP_CONVERTER
=
new
NoOpConverter
(
"NO_OP"
);
/**
* Used as a cache entry when no converter is available.
This converter is never
* returned.
* Used as a cache entry when no converter is available.
*
This converter is never
returned.
*/
private
static
final
GenericConverter
NO_MATCH
=
new
NoOpConverter
(
"NO_MATCH"
);
...
...
spring-expression/src/main/java/org/springframework/expression/EvaluationException.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -26,7 +26,24 @@ package org.springframework.expression;
public
class
EvaluationException
extends
ExpressionException
{
/**
* Creates a new expression evaluation exception.
* Create a new expression evaluation exception.
* @param message description of the problem that occurred
*/
public
EvaluationException
(
String
message
)
{
super
(
message
);
}
/**
* Create a new expression evaluation exception.
* @param message description of the problem that occurred
* @param cause the underlying cause of this exception
*/
public
EvaluationException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
/**
* Create a new expression evaluation exception.
* @param position the position in the expression where the problem occurred
* @param message description of the problem that occurred
*/
...
...
@@ -35,7 +52,7 @@ public class EvaluationException extends ExpressionException {
}
/**
* Create
s
a new expression evaluation exception.
* Create a new expression evaluation exception.
* @param expressionString the expression that could not be evaluated
* @param message description of the problem that occurred
*/
...
...
@@ -44,7 +61,7 @@ public class EvaluationException extends ExpressionException {
}
/**
* Create
s
a new expression evaluation exception.
* Create a new expression evaluation exception.
* @param position the position in the expression where the problem occurred
* @param message description of the problem that occurred
* @param cause the underlying cause of this exception
...
...
@@ -53,16 +70,4 @@ public class EvaluationException extends ExpressionException {
super
(
position
,
message
,
cause
);
}
/**
* Creates a new expression evaluation exception.
* @param message description of the problem that occurred
*/
public
EvaluationException
(
String
message
)
{
super
(
message
);
}
public
EvaluationException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
spring-expression/src/main/java/org/springframework/expression/ExpressionException.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -20,6 +20,7 @@ package org.springframework.expression;
* Super class for exceptions that can occur whilst processing expressions.
*
* @author Andy Clement
* @author Phil Webb
* @since 3.0
*/
@SuppressWarnings
(
"serial"
)
...
...
@@ -27,68 +28,68 @@ public class ExpressionException extends RuntimeException {
protected
String
expressionString
;
protected
int
position
;
// -1 if not known
- but
should be known in all reasonable cases
protected
int
position
;
// -1 if not known
;
should be known in all reasonable cases
/**
* Construct a new expression exception.
* @param expressionString the expression string
* @param message a descriptive message
*/
public
ExpressionException
(
String
expressionString
,
String
message
)
{
public
ExpressionException
(
String
message
)
{
super
(
message
);
this
.
position
=
-
1
;
this
.
expressionString
=
expressionString
;
}
/**
* Construct a new expression exception.
* @param expressionString the expression string
* @param position the position in the expression string where the problem occurred
* @param message a descriptive message
* @param cause the underlying cause of this exception
*/
public
ExpressionException
(
String
expressionString
,
int
position
,
String
message
)
{
super
(
message
);
this
.
position
=
position
;
this
.
expressionString
=
expressionString
;
public
ExpressionException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
/**
* Construct a new expression exception.
* @param
position the position in the expression string where the problem occurred
* @param
expressionString the expression string
* @param message a descriptive message
*/
public
ExpressionException
(
int
position
,
String
message
)
{
public
ExpressionException
(
String
expressionString
,
String
message
)
{
super
(
message
);
this
.
position
=
position
;
this
.
expressionString
=
expressionString
;
this
.
position
=
-
1
;
}
/**
* Construct a new expression exception.
* @param expressionString the expression string
* @param position the position in the expression string where the problem occurred
* @param message a descriptive message
* @param cause the underlying cause of this exception
*/
public
ExpressionException
(
int
position
,
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
public
ExpressionException
(
String
expressionString
,
int
position
,
String
message
)
{
super
(
message
);
this
.
expressionString
=
expressionString
;
this
.
position
=
position
;
}
/**
* Construct a new expression exception.
* @param position the position in the expression string where the problem occurred
* @param message a descriptive message
*/
public
ExpressionException
(
String
message
)
{
public
ExpressionException
(
int
position
,
String
message
)
{
super
(
message
);
this
.
position
=
position
;
}
/**
* Construct a new expression exception.
* @param position the position in the expression string where the problem occurred
* @param message a descriptive message
* @param cause the underlying cause of this exception
*/
public
ExpressionException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
public
ExpressionException
(
int
position
,
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
this
.
position
=
position
;
}
...
...
@@ -107,8 +108,9 @@ public class ExpressionException extends RuntimeException {
}
/**
* Return the exception message. Since Spring 4.0 this method returns the
* same result as {@link #toDetailedString()}.
* Return the exception message.
* As of Spring 4.0, this method returns the same result as {@link #toDetailedString()}.
* @see #getSimpleMessage()
* @see java.lang.Throwable#getMessage()
*/
@Override
...
...
@@ -142,6 +144,7 @@ public class ExpressionException extends RuntimeException {
/**
* Return the exception simple message without including the expression
* that caused the failure.
* @since 4.0
*/
public
String
getSimpleMessage
()
{
return
super
.
getMessage
();
...
...
spring-expression/src/main/java/org/springframework/expression/ParseException.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -26,7 +26,7 @@ package org.springframework.expression;
public
class
ParseException
extends
ExpressionException
{
/**
* Create
s
a new expression parsing exception.
* Create a new expression parsing exception.
* @param expressionString the expression string that could not be parsed
* @param position the position in the expression string where the problem occurred
* @param message description of the problem that occurred
...
...
@@ -36,7 +36,7 @@ public class ParseException extends ExpressionException {
}
/**
* Create
s
a new expression parsing exception.
* Create a new expression parsing exception.
* @param position the position in the expression string where the problem occurred
* @param message description of the problem that occurred
* @param cause the underlying cause of this exception
...
...
@@ -46,7 +46,7 @@ public class ParseException extends ExpressionException {
}
/**
* Create
s
a new expression parsing exception.
* Create a new expression parsing exception.
* @param position the position in the expression string where the problem occurred
* @param message description of the problem that occurred
*/
...
...
spring-expression/src/main/java/org/springframework/expression/spel/SpelEvaluationException.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.expression.spel
;
import
org.springframework.expression.EvaluationException
;
...
...
@@ -34,7 +35,7 @@ public class SpelEvaluationException extends EvaluationException {
public
SpelEvaluationException
(
SpelMessage
message
,
Object
...
inserts
)
{
super
(
message
.
formatMessage
(
0
,
inserts
));
// TODO poor position information, can the callers not really supply something?
super
(
message
.
formatMessage
(
0
,
inserts
));
this
.
message
=
message
;
this
.
inserts
=
inserts
;
}
...
...
@@ -45,54 +46,43 @@ public class SpelEvaluationException extends EvaluationException {
this
.
inserts
=
inserts
;
}
public
SpelEvaluationException
(
int
position
,
Throwable
cause
,
SpelMessage
message
,
Object
...
inserts
)
{
super
(
position
,
message
.
formatMessage
(
position
,
inserts
),
cause
);
public
SpelEvaluationException
(
int
position
,
Throwable
cause
,
SpelMessage
message
,
Object
...
inserts
)
{
super
(
position
,
message
.
formatMessage
(
position
,
inserts
),
cause
);
this
.
message
=
message
;
this
.
inserts
=
inserts
;
}
public
SpelEvaluationException
(
Throwable
cause
,
SpelMessage
message
,
Object
...
inserts
)
{
super
(
message
.
formatMessage
(
0
,
inserts
),
cause
);
super
(
message
.
formatMessage
(
0
,
inserts
),
cause
);
this
.
message
=
message
;
this
.
inserts
=
inserts
;
}
/**
*
@return a formatted message with inserts applied
*
Set the position in the related expression which gave rise to this exception.
*/
@Override
public
String
getMessage
()
{
if
(
this
.
message
!=
null
)
{
return
this
.
message
.
formatMessage
(
this
.
position
,
this
.
inserts
);
}
else
{
return
super
.
getMessage
();
}
public
void
setPosition
(
int
position
)
{
this
.
position
=
position
;
}
/**
*
@return the message code
*
Return the message code.
*/
public
SpelMessage
getMessageCode
()
{
return
this
.
message
;
}
/**
* Set the position in the related expression which gave rise to this exception.
*
* @param position the position in the expression that gave rise to the exception
*/
public
void
setPosition
(
int
position
)
{
this
.
position
=
position
;
}
/**
* @return the message inserts
* Return the message inserts.
*/
public
Object
[]
getInserts
()
{
return
this
.
inserts
;
}
@Override
public
String
getMessage
()
{
return
getSimpleMessage
();
}
}
spring-expression/src/main/java/org/springframework/expression/spel/SpelMessage.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
6
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,15 +24,13 @@ import java.text.MessageFormat;
* expect particular code numbers rather than particular text, enabling the message text
* to more easily be modified and the tests to run successfully in different locales.
*
* <p>When a message is formatted, it will have this kind of form
* <p>When a message is formatted, it will have this kind of form, capturing the prefix
* and the error kind, including the position if it is known:
*
* <pre class="code">
* EL1004E:
(pos 34): Type cannot be found 'String'
* EL1004E:(pos 34): Type cannot be found 'String'
* </pre>
*
* The prefix captures the code and the error kind, whilst the position is included
* if it is known.
*
* @author Andy Clement
* @since 3.0
*/
...
...
@@ -175,7 +173,7 @@ public enum SpelMessage {
"Cannot find terminating \" for string"
),
NON_TERMINATING_QUOTED_STRING
(
Kind
.
ERROR
,
1046
,
"Cannot find terminating ' for string"
),
"Cannot find terminating '
'
for string"
),
MISSING_LEADING_ZERO_FOR_NUMBER
(
Kind
.
ERROR
,
1047
,
"A real number must be prefixed by zero, it cannot start with just ''.''"
),
...
...
@@ -190,7 +188,7 @@ public enum SpelMessage {
"The arguments '(...)' for the constructor call are missing"
),
RUN_OUT_OF_ARGUMENTS
(
Kind
.
ERROR
,
1051
,
"Unexpected ran out of arguments"
),
"Unexpected
ly
ran out of arguments"
),
UNABLE_TO_GROW_COLLECTION
(
Kind
.
ERROR
,
1052
,
"Unable to grow collection"
),
...
...
@@ -262,7 +260,7 @@ public enum SpelMessage {
private
final
String
message
;
private
SpelMessage
(
Kind
kind
,
int
code
,
String
message
)
{
SpelMessage
(
Kind
kind
,
int
code
,
String
message
)
{
this
.
kind
=
kind
;
this
.
code
=
code
;
this
.
message
=
message
;
...
...
@@ -293,6 +291,6 @@ public enum SpelMessage {
}
public
static
enum
Kind
{
INFO
,
WARNING
,
ERROR
}
public
enum
Kind
{
INFO
,
WARNING
,
ERROR
}
}
spring-expression/src/main/java/org/springframework/expression/spel/SpelParseException.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.expression.spel
;
import
org.springframework.expression.ParseException
;
...
...
@@ -34,21 +35,21 @@ public class SpelParseException extends ParseException {
public
SpelParseException
(
String
expressionString
,
int
position
,
SpelMessage
message
,
Object
...
inserts
)
{
super
(
expressionString
,
position
,
message
.
formatMessage
(
position
,
inserts
));
super
(
expressionString
,
position
,
message
.
formatMessage
(
position
,
inserts
));
this
.
position
=
position
;
this
.
message
=
message
;
this
.
inserts
=
inserts
;
}
public
SpelParseException
(
int
position
,
SpelMessage
message
,
Object
...
inserts
)
{
super
(
position
,
message
.
formatMessage
(
position
,
inserts
));
super
(
position
,
message
.
formatMessage
(
position
,
inserts
));
this
.
position
=
position
;
this
.
message
=
message
;
this
.
inserts
=
inserts
;
}
public
SpelParseException
(
int
position
,
Throwable
cause
,
SpelMessage
message
,
Object
...
inserts
)
{
super
(
position
,
message
.
formatMessage
(
position
,
inserts
),
cause
);
super
(
position
,
message
.
formatMessage
(
position
,
inserts
),
cause
);
this
.
position
=
position
;
this
.
message
=
message
;
this
.
inserts
=
inserts
;
...
...
@@ -56,26 +57,22 @@ public class SpelParseException extends ParseException {
/**
* @return a formatted message with inserts applied
*/
@Override
public
String
getMessage
()
{
return
(
this
.
message
!=
null
?
this
.
message
.
formatMessage
(
this
.
position
,
this
.
inserts
)
:
super
.
getMessage
());
}
/**
* @return the message code
* Return the message code.
*/
public
SpelMessage
getMessageCode
()
{
return
this
.
message
;
}
/**
*
@return the message inserts
*
Return the message inserts.
*/
public
Object
[]
getInserts
()
{
return
this
.
inserts
;
}
@Override
public
String
getMessage
()
{
return
getSimpleMessage
();
}
}
spring-web/src/main/java/org/springframework/http/client/SimpleClientHttpRequestFactory.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -151,8 +151,7 @@ public class SimpleClientHttpRequestFactory implements ClientHttpRequestFactory,
*/
@Override
public
AsyncClientHttpRequest
createAsyncRequest
(
URI
uri
,
HttpMethod
httpMethod
)
throws
IOException
{
Assert
.
state
(
this
.
taskExecutor
!=
null
,
"Asynchronous execution requires an AsyncTaskExecutor to be set"
);
Assert
.
state
(
this
.
taskExecutor
!=
null
,
"Asynchronous execution requires TaskExecutor to be set"
);
HttpURLConnection
connection
=
openConnection
(
uri
.
toURL
(),
this
.
proxy
);
prepareConnection
(
connection
,
httpMethod
.
name
());
...
...
spring-web/src/main/java/org/springframework/web/util/UriTemplate.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -44,14 +44,14 @@ import org.springframework.util.Assert;
@SuppressWarnings
(
"serial"
)
public
class
UriTemplate
implements
Serializable
{
private
final
String
uriTemplate
;
private
final
UriComponents
uriComponents
;
private
final
List
<
String
>
variableNames
;
private
final
Pattern
matchPattern
;
private
final
String
uriTemplate
;
/**
* Construct a new {@code UriTemplate} with the given URI String.
...
...
@@ -105,7 +105,7 @@ public class UriTemplate implements Serializable {
* <p>Example:
* <pre class="code">
* UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
* System.out.println(template.expand("Rest & Relax",
"
42));
* System.out.println(template.expand("Rest & Relax", 42));
* </pre>
* will print: <blockquote>{@code http://example.com/hotels/Rest%20%26%20Relax/bookings/42}</blockquote>
* @param uriVariableValues the array of URI variables
...
...
@@ -173,7 +173,6 @@ public class UriTemplate implements Serializable {
private
final
Pattern
pattern
;
private
TemplateInfo
(
List
<
String
>
vars
,
Pattern
pattern
)
{
this
.
variableNames
=
vars
;
this
.
pattern
=
pattern
;
...
...
@@ -187,7 +186,7 @@ public class UriTemplate implements Serializable {
return
this
.
pattern
;
}
p
rivate
static
TemplateInfo
parse
(
String
uriTemplate
)
{
p
ublic
static
TemplateInfo
parse
(
String
uriTemplate
)
{
int
level
=
0
;
List
<
String
>
variableNames
=
new
ArrayList
<
String
>();
StringBuilder
pattern
=
new
StringBuilder
();
...
...
@@ -216,8 +215,7 @@ public class UriTemplate implements Serializable {
else
{
if
(
idx
+
1
==
variable
.
length
())
{
throw
new
IllegalArgumentException
(
"No custom regular expression specified after ':' "
+
"in \""
+
variable
+
"\""
);
"No custom regular expression specified after ':' in \""
+
variable
+
"\""
);
}
String
regex
=
variable
.
substring
(
idx
+
1
,
variable
.
length
());
pattern
.
append
(
'('
);
...
...
@@ -238,7 +236,7 @@ public class UriTemplate implements Serializable {
}
private
static
String
quote
(
StringBuilder
builder
)
{
return
builder
.
length
()
!=
0
?
Pattern
.
quote
(
builder
.
toString
())
:
""
;
return
(
builder
.
length
()
>
0
?
Pattern
.
quote
(
builder
.
toString
())
:
""
)
;
}
}
...
...
spring-web/src/test/java/org/springframework/web/client/AbstractJettyServerTestCase.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -33,13 +33,11 @@ import org.apache.commons.fileupload.FileItemFactory;
import
org.apache.commons.fileupload.FileUploadException
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.eclipse.jetty.server.Connector
;
import
org.eclipse.jetty.server.NetworkConnector
;
import
org.eclipse.jetty.server.Server
;
import
org.eclipse.jetty.servlet.ServletContextHandler
;
import
org.eclipse.jetty.servlet.ServletHolder
;
import
org.junit.AfterClass
;
import
org.junit.BeforeClass
;
...
...
@@ -56,11 +54,12 @@ public class AbstractJettyServerTestCase {
protected
static
final
String
helloWorld
=
"H\u00e9llo W\u00f6rld"
;
protected
static
final
MediaType
textContentType
=
new
MediaType
(
"text"
,
"plain"
,
Collections
.
singletonMap
(
"charset"
,
"UTF-8"
));
protected
static
final
MediaType
textContentType
=
new
MediaType
(
"text"
,
"plain"
,
Collections
.
singletonMap
(
"charset"
,
"UTF-8"
));
protected
static
final
MediaType
jsonContentType
=
new
MediaType
(
"application"
,
"json"
,
Collections
.
singletonMap
(
"charset"
,
"UTF-8"
));
protected
static
final
MediaType
jsonContentType
=
new
MediaType
(
"application"
,
"json"
,
Collections
.
singletonMap
(
"charset"
,
"utf-8"
));
private
static
Server
jettyServer
;
...
...
@@ -71,7 +70,6 @@ public class AbstractJettyServerTestCase {
@BeforeClass
public
static
void
startJettyServer
()
throws
Exception
{
// Let server pick its own random, available port.
jettyServer
=
new
Server
(
0
);
...
...
@@ -114,39 +112,41 @@ public class AbstractJettyServerTestCase {
}
}
/** Servlet that sets the given status code. */
@SuppressWarnings
(
"serial"
)
private
static
class
StatusCodeServlet
extends
GenericServlet
{
private
final
int
sc
;
p
rivate
StatusCodeServlet
(
int
sc
)
{
p
ublic
StatusCodeServlet
(
int
sc
)
{
this
.
sc
=
sc
;
}
@Override
public
void
service
(
ServletRequest
request
,
ServletResponse
response
)
throws
ServletException
,
IOException
{
public
void
service
(
ServletRequest
request
,
ServletResponse
response
)
throws
IOException
{
((
HttpServletResponse
)
response
).
setStatus
(
sc
);
}
}
/** Servlet that returns an error message for a given status code. */
@SuppressWarnings
(
"serial"
)
private
static
class
ErrorServlet
extends
GenericServlet
{
private
final
int
sc
;
p
rivate
ErrorServlet
(
int
sc
)
{
p
ublic
ErrorServlet
(
int
sc
)
{
this
.
sc
=
sc
;
}
@Override
public
void
service
(
ServletRequest
request
,
ServletResponse
response
)
throws
ServletException
,
IOException
{
public
void
service
(
ServletRequest
request
,
ServletResponse
response
)
throws
IOException
{
((
HttpServletResponse
)
response
).
sendError
(
sc
);
}
}
@SuppressWarnings
(
"serial"
)
private
static
class
GetServlet
extends
HttpServlet
{
...
...
@@ -154,14 +154,13 @@ public class AbstractJettyServerTestCase {
private
final
MediaType
contentType
;
p
rivate
GetServlet
(
byte
[]
buf
,
MediaType
contentType
)
{
p
ublic
GetServlet
(
byte
[]
buf
,
MediaType
contentType
)
{
this
.
buf
=
buf
;
this
.
contentType
=
contentType
;
}
@Override
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
if
(
contentType
!=
null
)
{
response
.
setContentType
(
contentType
.
toString
());
}
...
...
@@ -170,10 +169,11 @@ public class AbstractJettyServerTestCase {
}
}
@SuppressWarnings
(
"serial"
)
private
static
class
PostServlet
extends
HttpServlet
{
private
final
String
s
;
private
final
String
content
;
private
final
String
location
;
...
...
@@ -181,20 +181,19 @@ public class AbstractJettyServerTestCase {
private
final
MediaType
contentType
;
p
rivate
PostServlet
(
String
s
,
String
location
,
byte
[]
buf
,
MediaType
contentType
)
{
this
.
s
=
s
;
p
ublic
PostServlet
(
String
content
,
String
location
,
byte
[]
buf
,
MediaType
contentType
)
{
this
.
content
=
content
;
this
.
location
=
location
;
this
.
buf
=
buf
;
this
.
contentType
=
contentType
;
}
@Override
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
assertTrue
(
"Invalid request content-length"
,
request
.
getContentLength
()
>
0
);
assertNotNull
(
"No content-type"
,
request
.
getContentType
());
String
body
=
FileCopyUtils
.
copyToString
(
request
.
getReader
());
assertEquals
(
"Invalid request body"
,
s
,
body
);
assertEquals
(
"Invalid request body"
,
content
,
body
);
response
.
setStatus
(
HttpServletResponse
.
SC_CREATED
);
response
.
setHeader
(
"Location"
,
baseUrl
+
location
);
response
.
setContentLength
(
buf
.
length
);
...
...
@@ -203,6 +202,7 @@ public class AbstractJettyServerTestCase {
}
}
@SuppressWarnings
(
"serial"
)
private
static
class
JsonPostServlet
extends
HttpServlet
{
...
...
@@ -210,14 +210,13 @@ public class AbstractJettyServerTestCase {
private
final
MediaType
contentType
;
p
rivate
JsonPostServlet
(
String
location
,
MediaType
contentType
)
{
p
ublic
JsonPostServlet
(
String
location
,
MediaType
contentType
)
{
this
.
location
=
location
;
this
.
contentType
=
contentType
;
}
@Override
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
assertTrue
(
"Invalid request content-length"
,
request
.
getContentLength
()
>
0
);
assertNotNull
(
"No content-type"
,
request
.
getContentType
());
String
body
=
FileCopyUtils
.
copyToString
(
request
.
getReader
());
...
...
@@ -230,18 +229,18 @@ public class AbstractJettyServerTestCase {
}
}
@SuppressWarnings
(
"serial"
)
private
static
class
PutServlet
extends
HttpServlet
{
private
final
String
s
;
p
rivate
PutServlet
(
String
s
,
byte
[]
buf
,
MediaType
contentType
)
{
p
ublic
PutServlet
(
String
s
,
byte
[]
buf
,
MediaType
contentType
)
{
this
.
s
=
s
;
}
@Override
protected
void
doPut
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doPut
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
assertTrue
(
"Invalid request content-length"
,
request
.
getContentLength
()
>
0
);
assertNotNull
(
"No content-type"
,
request
.
getContentType
());
String
body
=
FileCopyUtils
.
copyToString
(
request
.
getReader
());
...
...
@@ -250,17 +249,19 @@ public class AbstractJettyServerTestCase {
}
}
@SuppressWarnings
(
"serial"
)
private
static
class
UriServlet
extends
HttpServlet
{
@Override
protected
void
doGet
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
protected
void
doGet
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
IOException
{
resp
.
setContentType
(
"text/plain"
);
resp
.
setCharacterEncoding
(
"utf-8"
);
resp
.
getWriter
().
write
(
req
.
getRequestURI
());
}
}
@SuppressWarnings
(
"serial"
)
private
static
class
MultipartServlet
extends
HttpServlet
{
...
...
@@ -300,13 +301,13 @@ public class AbstractJettyServerTestCase {
}
}
@SuppressWarnings
(
"serial"
)
private
static
class
FormServlet
extends
HttpServlet
{
@Override
protected
void
doPost
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
assertEquals
(
MediaType
.
APPLICATION_FORM_URLENCODED_VALUE
,
req
.
getContentType
());
protected
void
doPost
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
IOException
{
assertEquals
(
MediaType
.
APPLICATION_FORM_URLENCODED_VALUE
,
req
.
getContentType
());
Map
<
String
,
String
[]>
parameters
=
req
.
getParameterMap
();
assertEquals
(
2
,
parameters
.
size
());
...
...
@@ -322,15 +323,14 @@ public class AbstractJettyServerTestCase {
}
}
@SuppressWarnings
(
"serial"
)
private
static
class
DeleteServlet
extends
HttpServlet
{
@Override
protected
void
doDelete
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
ServletException
,
IOException
{
protected
void
doDelete
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
IOException
{
resp
.
setStatus
(
200
);
}
}
}
spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java
浏览文件 @
0b76b13d
...
...
@@ -114,7 +114,6 @@ public class AsyncRestTemplateIntegrationTests extends AbstractJettyServerTestCa
assertNull
(
"Invalid content"
,
entity
.
getBody
());
}
@Test
public
void
getNoContentTypeHeader
()
throws
Exception
{
Future
<
ResponseEntity
<
byte
[]>>
futureEntity
=
template
.
getForEntity
(
baseUrl
+
"/get/nocontenttype"
,
byte
[].
class
);
...
...
@@ -122,7 +121,6 @@ public class AsyncRestTemplateIntegrationTests extends AbstractJettyServerTestCa
assertArrayEquals
(
"Invalid content"
,
helloWorld
.
getBytes
(
"UTF-8"
),
responseEntity
.
getBody
());
}
@Test
public
void
getNoContent
()
throws
Exception
{
Future
<
ResponseEntity
<
String
>>
responseFuture
=
template
.
getForEntity
(
baseUrl
+
"/status/nocontent"
,
String
.
class
);
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/ResourceServlet.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -175,8 +175,8 @@ public class ResourceServlet extends HttpServletBean {
}
/**
* Return a
PathMatcher
to use for matching the "allowedResources" URL pattern.
*
Default is AntPathMatcher
.
* Return a
{@link PathMatcher}
to use for matching the "allowedResources" URL pattern.
*
<p>The default is {@link AntPathMatcher}
.
* @see #setAllowedResources
* @see org.springframework.util.AntPathMatcher
*/
...
...
@@ -191,9 +191,9 @@ public class ResourceServlet extends HttpServletBean {
*/
@Override
protected
final
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
throws
ServletException
,
IOException
{
//
determine URL of resource to include
//
Determine URL of resource to include...
String
resourceUrl
=
determineResourceUrl
(
request
);
if
(
resourceUrl
!=
null
)
{
...
...
@@ -220,7 +220,7 @@ public class ResourceServlet extends HttpServletBean {
}
}
//
n
o resource URL specified -> try to include default URL.
//
N
o resource URL specified -> try to include default URL.
else
if
(!
includeDefaultUrl
(
request
,
response
))
{
throw
new
ServletException
(
"No target resource URL found for request"
);
}
...
...
@@ -265,23 +265,23 @@ public class ResourceServlet extends HttpServletBean {
* @throws IOException if thrown by the RequestDispatcher
*/
private
void
doInclude
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
resourceUrl
)
throws
ServletException
,
IOException
{
throws
ServletException
,
IOException
{
if
(
this
.
contentType
!=
null
)
{
response
.
setContentType
(
this
.
contentType
);
}
String
[]
resourceUrls
=
StringUtils
.
tokenizeToStringArray
(
resourceUrl
,
RESOURCE_URL_DELIMITERS
);
for
(
int
i
=
0
;
i
<
resourceUrls
.
length
;
i
++
)
{
//
c
heck whether URL matches allowed resources
if
(
this
.
allowedResources
!=
null
&&
!
this
.
pathMatcher
.
match
(
this
.
allowedResources
,
resourceUrls
[
i
]
))
{
throw
new
ServletException
(
"Resource ["
+
resourceUrls
[
i
]
+
String
[]
resourceUrls
=
StringUtils
.
tokenizeToStringArray
(
resourceUrl
,
RESOURCE_URL_DELIMITERS
);
for
(
String
url
:
resourceUrls
)
{
//
C
heck whether URL matches allowed resources
if
(
this
.
allowedResources
!=
null
&&
!
this
.
pathMatcher
.
match
(
this
.
allowedResources
,
url
))
{
throw
new
ServletException
(
"Resource ["
+
url
+
"] does not match allowed pattern ["
+
this
.
allowedResources
+
"]"
);
}
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Including resource ["
+
resourceUrls
[
i
]
+
"]"
);
logger
.
debug
(
"Including resource ["
+
url
+
"]"
);
}
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
resourceUrls
[
i
]
);
RequestDispatcher
rd
=
request
.
getRequestDispatcher
(
url
);
rd
.
include
(
request
,
response
);
}
}
...
...
@@ -309,8 +309,8 @@ public class ResourceServlet extends HttpServletBean {
if
(
resourceUrl
!=
null
)
{
String
[]
resourceUrls
=
StringUtils
.
tokenizeToStringArray
(
resourceUrl
,
RESOURCE_URL_DELIMITERS
);
long
latestTimestamp
=
-
1
;
for
(
int
i
=
0
;
i
<
resourceUrls
.
length
;
i
++
)
{
long
timestamp
=
getFileTimestamp
(
resourceUrls
[
i
]
);
for
(
String
url
:
resourceUrls
)
{
long
timestamp
=
getFileTimestamp
(
url
);
if
(
timestamp
>
latestTimestamp
)
{
latestTimestamp
=
timestamp
;
}
...
...
@@ -336,8 +336,10 @@ public class ResourceServlet extends HttpServletBean {
return
lastModifiedTime
;
}
catch
(
IOException
ex
)
{
logger
.
warn
(
"Couldn't retrieve last-modified timestamp of ["
+
resource
+
"] - using ResourceServlet startup time"
);
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
"Couldn't retrieve last-modified timestamp of "
+
resource
+
" - using ResourceServlet startup time"
);
}
return
-
1
;
}
}
...
...
spring-websocket/src/main/java/org/springframework/web/socket/WebSocketMessage.java
浏览文件 @
0b76b13d
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
6
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.
...
...
@@ -25,11 +25,10 @@ package org.springframework.web.socket;
public
interface
WebSocketMessage
<
T
>
{
/**
* Return
s the message payload. This will never be {@code null}
.
* Return
the message payload (never {@code null})
.
*/
T
getPayload
();
/**
* Return the number of bytes contained in the message.
*/
...
...
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java
浏览文件 @
0b76b13d
...
...
@@ -80,10 +80,10 @@ public abstract class AbstractSockJsSession implements SockJsSession {
private
static
final
Set
<
String
>
disconnectedClientExceptions
;
static
{
Set
<
String
>
set
=
new
HashSet
<
String
>(
2
);
set
.
add
(
"ClientAbortException"
);
// Tomcat
set
.
add
(
"EOFException"
);
// Tomcat
set
.
add
(
"EofException"
);
// Jetty
Set
<
String
>
set
=
new
HashSet
<
String
>(
4
);
set
.
add
(
"ClientAbortException"
);
// Tomcat
set
.
add
(
"EOFException"
);
// Tomcat
set
.
add
(
"EofException"
);
// Jetty
// java.io.IOException "Broken pipe" on WildFly, Glassfish (already covered)
disconnectedClientExceptions
=
Collections
.
unmodifiableSet
(
set
);
}
...
...
@@ -208,7 +208,7 @@ public abstract class AbstractSockJsSession implements SockJsSession {
writeFrameInternal
(
SockJsFrame
.
closeFrame
(
status
.
getCode
(),
status
.
getReason
()));
}
catch
(
Throwable
ex
)
{
logger
.
debug
(
"Failure while send SockJS close frame"
,
ex
);
logger
.
debug
(
"Failure while send
ing
SockJS close frame"
,
ex
);
}
}
updateLastActiveTime
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录