Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿信在这里
SkyWalking
提交
2c822363
S
SkyWalking
项目概览
阿信在这里
/
SkyWalking
与 Fork 源项目一致
Fork自
山不在高_有仙则灵 / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2c822363
编写于
6月 06, 2018
作者:
S
SevenPointOld
提交者:
wu-sheng
6月 06, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Spring mvc plugin auto add '/' if necessary (#1315)
* spring mvc plugin auto add '/' if necessary
上级
5ba4f647
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
4 deletion
+40
-4
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/mvc/v4/ControllerConstructorInterceptorTest.java
...n/spring/mvc/v4/ControllerConstructorInterceptorTest.java
+3
-3
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/mvc/v4/PathMappingCacheTest.java
...alking/apm/plugin/spring/mvc/v4/PathMappingCacheTest.java
+25
-1
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/PathMappingCache.java
...lking/apm/plugin/spring/mvc/commons/PathMappingCache.java
+12
-0
未找到文件。
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/mvc/v4/ControllerConstructorInterceptorTest.java
浏览文件 @
2c822363
...
...
@@ -54,7 +54,7 @@ public class ControllerConstructorInterceptorTest {
Method
m
=
obj
.
getClass
().
getMethods
()[
0
];
cache
.
addPathMapping
(
m
,
"#toString"
);
Assert
.
assertEquals
(
"the two value should be equal"
,
cache
.
findPathMapping
(
m
),
"/test1#toString"
);
Assert
.
assertEquals
(
"the two value should be equal"
,
cache
.
findPathMapping
(
m
),
"/test1
/
#toString"
);
}
@Test
...
...
@@ -67,7 +67,7 @@ public class ControllerConstructorInterceptorTest {
Method
m
=
obj
.
getClass
().
getMethods
()[
0
];
cache
.
addPathMapping
(
m
,
"#toString"
);
Assert
.
assertEquals
(
"the two value should be equal"
,
cache
.
findPathMapping
(
m
),
"#toString"
);
Assert
.
assertEquals
(
"the two value should be equal"
,
cache
.
findPathMapping
(
m
),
"
/
#toString"
);
}
@Test
...
...
@@ -80,7 +80,7 @@ public class ControllerConstructorInterceptorTest {
Method
m
=
obj
.
getClass
().
getMethods
()[
0
];
cache
.
addPathMapping
(
m
,
"#toString"
);
Assert
.
assertEquals
(
"the two value should be equal"
,
cache
.
findPathMapping
(
m
),
"/test3#toString"
);
Assert
.
assertEquals
(
"the two value should be equal"
,
cache
.
findPathMapping
(
m
),
"/test3
/
#toString"
);
}
@RequestMapping
(
value
=
"/test1"
)
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/mvc/v4/PathMappingCacheTest.java
浏览文件 @
2c822363
...
...
@@ -45,7 +45,31 @@ public class PathMappingCacheTest {
Method
m
=
obj
.
getClass
().
getMethods
()[
0
];
pathMappingCache
.
addPathMapping
(
m
,
"#toString"
);
Assert
.
assertEquals
(
"the two value should be equal"
,
pathMappingCache
.
findPathMapping
(
m
),
"
org.apache.skywalking.apm.plugin.spring.mvc
#toString"
);
Assert
.
assertEquals
(
"the two value should be equal"
,
pathMappingCache
.
findPathMapping
(
m
),
"
/org.apache.skywalking.apm.plugin.spring.mvc/
#toString"
);
}
@Test
public
void
testAutoAddPathSeparator
()
{
String
rightPath
=
"/root/sub"
;
Object
obj
=
new
Object
();
Method
m
=
obj
.
getClass
().
getMethods
()[
0
];
PathMappingCache
cache
=
new
PathMappingCache
(
"root"
);
cache
.
addPathMapping
(
m
,
"sub"
);
Assert
.
assertEquals
(
cache
.
findPathMapping
(
m
),
rightPath
);
PathMappingCache
cache2
=
new
PathMappingCache
(
"/root"
);
cache2
.
addPathMapping
(
m
,
"/sub"
);
Assert
.
assertEquals
(
cache2
.
findPathMapping
(
m
),
rightPath
);
PathMappingCache
cache3
=
new
PathMappingCache
(
"root"
);
cache3
.
addPathMapping
(
m
,
"/sub"
);
Assert
.
assertEquals
(
cache3
.
findPathMapping
(
m
),
rightPath
);
PathMappingCache
cache4
=
new
PathMappingCache
(
"/root"
);
cache4
.
addPathMapping
(
m
,
"sub"
);
Assert
.
assertEquals
(
cache4
.
findPathMapping
(
m
),
rightPath
);
}
}
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/PathMappingCache.java
浏览文件 @
2c822363
...
...
@@ -19,6 +19,8 @@
package
org.apache.skywalking.apm.plugin.spring.mvc.commons
;
import
org.apache.skywalking.apm.util.StringUtil
;
import
java.lang.reflect.Method
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -28,11 +30,17 @@ import java.util.concurrent.ConcurrentHashMap;
* @author zhangxin
*/
public
class
PathMappingCache
{
private
static
final
String
PATH_SEPARATOR
=
"/"
;
private
String
classPath
=
""
;
private
ConcurrentHashMap
<
Method
,
String
>
methodPathMapping
=
new
ConcurrentHashMap
<
Method
,
String
>();
public
PathMappingCache
(
String
classPath
)
{
if
(!
StringUtil
.
isEmpty
(
classPath
)
&&
!
classPath
.
startsWith
(
PATH_SEPARATOR
))
{
classPath
=
PATH_SEPARATOR
+
classPath
;
}
this
.
classPath
=
classPath
;
}
...
...
@@ -41,6 +49,10 @@ public class PathMappingCache {
}
public
void
addPathMapping
(
Method
method
,
String
methodPath
)
{
if
(!
StringUtil
.
isEmpty
(
methodPath
)
&&
!
methodPath
.
startsWith
(
PATH_SEPARATOR
)
&&
!
classPath
.
endsWith
(
PATH_SEPARATOR
))
{
methodPath
=
PATH_SEPARATOR
+
methodPath
;
}
methodPathMapping
.
put
(
method
,
classPath
+
methodPath
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录