Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzh_me
Sureness
提交
110e8dd7
Sureness
项目概览
lzh_me
/
Sureness
与 Fork 源项目一致
Fork自
sureness / Sureness
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Sureness
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
110e8dd7
编写于
1月 19, 2021
作者:
sinat_25235033
提交者:
GitHub
1月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code analysis bug (#56)
上级
70f08583
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
37 deletion
+44
-37
core/src/main/java/com/usthe/sureness/provider/ducument/DocumentResourceAccess.java
...he/sureness/provider/ducument/DocumentResourceAccess.java
+23
-16
core/src/main/java/com/usthe/sureness/util/ClassScanner.java
core/src/main/java/com/usthe/sureness/util/ClassScanner.java
+19
-19
core/src/main/java/com/usthe/sureness/util/SurenessCommonUtil.java
...main/java/com/usthe/sureness/util/SurenessCommonUtil.java
+2
-2
未找到文件。
core/src/main/java/com/usthe/sureness/provider/ducument/DocumentResourceAccess.java
浏览文件 @
110e8dd7
...
...
@@ -41,25 +41,32 @@ public class DocumentResourceAccess {
*/
public
static
DocumentResourceEntity
loadConfig
(
String
yamlFileName
)
throws
IOException
{
Yaml
yaml
=
new
Yaml
();
InputStream
inputStream
=
DocumentResourceAccess
.
class
.
getClassLoader
().
getResourceAsStream
(
yamlFileName
);
if
(
inputStream
==
null
)
{
inputStream
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
yamlFileName
);
}
if
(
inputStream
==
null
)
{
File
yamlFile
=
new
File
(
yamlFileName
);
if
(
yamlFile
.
exists
())
{
try
(
FileInputStream
fileInputStream
=
new
FileInputStream
(
yamlFile
))
{
return
yaml
.
loadAs
(
fileInputStream
,
DocumentResourceEntity
.
class
);
}
catch
(
IOException
e
)
{
throw
new
IOException
(
e
);
InputStream
inputStream
=
null
;
try
{
inputStream
=
DocumentResourceAccess
.
class
.
getClassLoader
().
getResourceAsStream
(
yamlFileName
);
if
(
inputStream
==
null
)
{
inputStream
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
yamlFileName
);
}
if
(
inputStream
==
null
)
{
File
yamlFile
=
new
File
(
yamlFileName
);
if
(
yamlFile
.
exists
())
{
try
(
FileInputStream
fileInputStream
=
new
FileInputStream
(
yamlFile
))
{
return
yaml
.
loadAs
(
fileInputStream
,
DocumentResourceEntity
.
class
);
}
catch
(
IOException
e
)
{
throw
new
IOException
(
e
);
}
}
}
if
(
inputStream
==
null
)
{
throw
new
FileNotFoundException
(
"sureness file: "
+
DEFAULT_FILE_NAME
+
" not found, "
+
"please create the file if you need config resource"
);
}
return
yaml
.
loadAs
(
inputStream
,
DocumentResourceEntity
.
class
);
}
finally
{
if
(
inputStream
!=
null
)
{
inputStream
.
close
();
}
}
if
(
inputStream
==
null
)
{
throw
new
FileNotFoundException
(
"sureness file: "
+
DEFAULT_FILE_NAME
+
" not found, "
+
"please create the file if you need config resource"
);
}
return
yaml
.
loadAs
(
inputStream
,
DocumentResourceEntity
.
class
);
}
/**
...
...
core/src/main/java/com/usthe/sureness/util/ClassScanner.java
浏览文件 @
110e8dd7
...
...
@@ -240,30 +240,30 @@ public enum ClassScanner {
private
static
List
<
Class
<?>>
recursiveScan4Jar
(
String
pkg
,
String
jarPath
)
throws
IOException
{
List
<
Class
<?>>
classList
=
new
LinkedList
<>();
JarInputStream
jin
=
new
JarInputStream
(
new
FileInputStream
(
jarPath
));
JarEntry
entry
=
jin
.
getNextJarEntry
();
while
(
entry
!=
null
)
{
String
name
=
entry
.
getName
();
entry
=
jin
.
getNextJarEntry
();
if
(!
name
.
contains
(
package2Path
(
pkg
)))
{
continue
;
}
if
(
isClass
(
name
))
{
if
(
isAnonymousInnerClass
(
name
))
{
try
(
JarInputStream
jin
=
new
JarInputStream
(
new
FileInputStream
(
jarPath
)))
{
JarEntry
entry
=
jin
.
getNextJarEntry
();
while
(
entry
!=
null
)
{
String
name
=
entry
.
getName
();
entry
=
jin
.
getNextJarEntry
();
if
(!
name
.
contains
(
package2Path
(
pkg
)))
{
continue
;
}
String
className
=
classFile2SimpleClass
(
path2Package
(
name
));
try
{
Class
<?>
clz
=
Thread
.
currentThread
().
getContextClassLoader
().
loadClass
(
className
);
classList
.
add
(
clz
);
}
catch
(
ClassNotFoundException
|
LinkageError
e
)
{
log
.
error
(
"Warning: Can not load class: {}"
,
className
);
if
(
isClass
(
name
))
{
if
(
isAnonymousInnerClass
(
name
))
{
continue
;
}
String
className
=
classFile2SimpleClass
(
path2Package
(
name
));
try
{
Class
<?>
clz
=
Thread
.
currentThread
().
getContextClassLoader
().
loadClass
(
className
);
classList
.
add
(
clz
);
}
catch
(
ClassNotFoundException
|
LinkageError
e
)
{
log
.
error
(
"Warning: Can not load class: {}"
,
className
);
}
}
}
}
return
classList
;
}
...
...
core/src/main/java/com/usthe/sureness/util/SurenessCommonUtil.java
浏览文件 @
110e8dd7
...
...
@@ -21,6 +21,7 @@ public class SurenessCommonUtil {
private
static
final
String
PATH_SPLIT
=
"/"
;
private
static
final
String
RANDOM_CHAR
=
"abcdefghijklmnopqrstuvwxyz0123456789"
;
private
static
final
Random
RANDOM
=
new
Random
();
/**
* match the userAgent
...
...
@@ -58,10 +59,9 @@ public class SurenessCommonUtil {
if
(
length
<
1
)
{
length
=
6
;
}
Random
random
=
new
Random
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
int
number
=
random
.
nextInt
(
RANDOM_CHAR
.
length
());
int
number
=
RANDOM
.
nextInt
(
RANDOM_CHAR
.
length
());
sb
.
append
(
RANDOM_CHAR
.
charAt
(
number
));
}
return
sb
.
toString
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录