Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
6dc73469
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 搜索 >>
提交
6dc73469
编写于
11月 13, 2017
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MethodReference treats proxy-targeting expressions as non-compilable
Issue: SPR-16191 (cherry picked from commit
c30145d6
)
上级
59d654b0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
4 deletion
+28
-4
spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
.../springframework/expression/spel/ast/MethodReference.java
+8
-3
spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java
...a/org/springframework/expression/spel/SpelReproTests.java
+20
-1
未找到文件。
spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
浏览文件 @
6dc73469
...
...
@@ -19,6 +19,7 @@ package org.springframework.expression.spel.ast;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.lang.reflect.Proxy
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -257,7 +258,8 @@ public class MethodReference extends SpelNodeImpl {
@Override
public
boolean
isCompilable
()
{
CachedMethodExecutor
executorToCheck
=
this
.
cachedExecutor
;
if
(
executorToCheck
==
null
||
!(
executorToCheck
.
get
()
instanceof
ReflectiveMethodExecutor
))
{
if
(
executorToCheck
==
null
||
executorToCheck
.
hasProxyTarget
()
||
!(
executorToCheck
.
get
()
instanceof
ReflectiveMethodExecutor
))
{
return
false
;
}
...
...
@@ -271,8 +273,7 @@ public class MethodReference extends SpelNodeImpl {
if
(
executor
.
didArgumentConversionOccur
())
{
return
false
;
}
Method
method
=
executor
.
getMethod
();
Class
<?>
clazz
=
method
.
getDeclaringClass
();
Class
<?>
clazz
=
executor
.
getMethod
().
getDeclaringClass
();
if
(!
Modifier
.
isPublic
(
clazz
.
getModifiers
())
&&
executor
.
getPublicDeclaringClass
()
==
null
)
{
return
false
;
}
...
...
@@ -385,6 +386,10 @@ public class MethodReference extends SpelNodeImpl {
this
.
target
.
equals
(
target
)
&&
this
.
argumentTypes
.
equals
(
argumentTypes
));
}
public
boolean
hasProxyTarget
()
{
return
(
this
.
target
!=
null
&&
Proxy
.
isProxyClass
(
this
.
target
.
getType
()));
}
public
MethodExecutor
get
()
{
return
this
.
methodExecutor
;
}
...
...
spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java
浏览文件 @
6dc73469
...
...
@@ -724,13 +724,32 @@ public class SpelReproTests extends AbstractExpressionTests {
VarargsReceiver
receiver
=
new
VarargsReceiver
();
VarargsInterface
proxy
=
(
VarargsInterface
)
Proxy
.
newProxyInstance
(
getClass
().
getClassLoader
(),
new
Class
<?>[]{
VarargsInterface
.
class
},
getClass
().
getClassLoader
(),
new
Class
<?>[]
{
VarargsInterface
.
class
},
(
proxy1
,
method
,
args
)
->
method
.
invoke
(
receiver
,
args
));
assertEquals
(
"OK"
,
expr
.
getValue
(
new
StandardEvaluationContext
(
receiver
)));
assertEquals
(
"OK"
,
expr
.
getValue
(
new
StandardEvaluationContext
(
proxy
)));
}
@Test
public
void
testCompiledExpressionForProxy_SPR16191
()
{
SpelExpressionParser
expressionParser
=
new
SpelExpressionParser
(
new
SpelParserConfiguration
(
SpelCompilerMode
.
IMMEDIATE
,
null
));
Expression
expression
=
expressionParser
.
parseExpression
(
"#target.process(#root)"
);
VarargsReceiver
receiver
=
new
VarargsReceiver
();
VarargsInterface
proxy
=
(
VarargsInterface
)
Proxy
.
newProxyInstance
(
getClass
().
getClassLoader
(),
new
Class
<?>[]
{
VarargsInterface
.
class
},
(
proxy1
,
method
,
args
)
->
method
.
invoke
(
receiver
,
args
));
StandardEvaluationContext
evaluationContext
=
new
StandardEvaluationContext
();
evaluationContext
.
setVariable
(
"target"
,
proxy
);
String
result
=
expression
.
getValue
(
evaluationContext
,
"foo"
,
String
.
class
);
result
=
expression
.
getValue
(
evaluationContext
,
"foo"
,
String
.
class
);
assertEquals
(
"OK"
,
result
);
}
@Test
public
void
varargsAndPrimitives_SPR8174
()
throws
Exception
{
EvaluationContext
emptyEvalContext
=
new
StandardEvaluationContext
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录