File tree Expand file tree Collapse file tree 11 files changed +88
-71
lines changed
dongtai-api-gather-openapi
dongtai-api-gather-spring-api
src/main/java/io/dongtai/iast/api/gather/spring/extractor
main/java/io/dongtai/iast/common/utils
test/java/io/dongtai/iast/common/utils Expand file tree Collapse file tree 11 files changed +88
-71
lines changed Original file line number Diff line number Diff line change 2525 <version >${commons-lang3.version} </version >
2626 </dependency >
2727
28- <dependency >
29- <groupId >junit</groupId >
30- <artifactId >junit</artifactId >
31- <version >${junit.version} </version >
32- <scope >test</scope >
33- </dependency >
34-
3528 <dependency >
3629 <groupId >org.json</groupId >
3730 <artifactId >json</artifactId >
Original file line number Diff line number Diff line change 2424 <version >${fastjson2.version} </version >
2525 <scope >provided</scope >
2626 </dependency >
27- <dependency >
28- <groupId >junit</groupId >
29- <artifactId >junit</artifactId >
30- <version >${junit.version} </version >
31- <scope >test</scope >
32- </dependency >
3327 </dependencies >
3428
3529</project >
Original file line number Diff line number Diff line change 3030 <version >${project.version} </version >
3131 <scope >provided</scope >
3232 </dependency >
33- <dependency >
34- <groupId >junit</groupId >
35- <artifactId >junit</artifactId >
36- <version >${junit.version} </version >
37- <scope >test</scope >
38- </dependency >
3933 </dependencies >
4034
4135 <build >
Original file line number Diff line number Diff line change 22
33import io .dongtai .iast .api .gather .spring .convertor .RequestMappingHandlerMappingConvertor ;
44import io .dongtai .iast .api .openapi .domain .OpenApi ;
5+ import io .dongtai .iast .common .utils .ExceptionUtil ;
56import io .dongtai .log .DongTaiLog ;
67import org .springframework .web .context .WebApplicationContext ;
78import org .springframework .web .servlet .mvc .method .annotation .RequestMappingHandlerMapping ;
@@ -72,7 +73,11 @@ private List<RequestMappingHandlerMapping> findRequestMappingHandlerMapping(WebA
7273 }
7374 }
7475 } catch (Throwable e ) {
75- DongTaiLog .debug ("try use BeanFactoryUtils find RequestMappingHandlerMapping exception" , e );
76+ // 仅在出现预期外错误的时候才打印日志
77+ String s = ExceptionUtil .getPrintStackTraceString (e );
78+ if (!s .contains ("java.lang.NoSuchMethodException: org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors()" )) {
79+ DongTaiLog .debug ("try use BeanFactoryUtils throw RequestMappingHandlerMapping exception" , e );
80+ }
7681 }
7782
7883 // 没有工具类,就只从自己里面找
Original file line number Diff line number Diff line change 1818 <module >dongtai-api-gather-dubbo-api</module >
1919 </modules >
2020
21+ <dependencies >
22+ <dependency >
23+ <groupId >io.dongtai.iast</groupId >
24+ <artifactId >dongtai-common</artifactId >
25+ <version >${revision} </version >
26+ <scope >compile</scope >
27+ </dependency >
28+ </dependencies >
29+
2130</project >
Original file line number Diff line number Diff line change 3737 <artifactId >fastjson2</artifactId >
3838 <version >${fastjson2.version} </version >
3939 </dependency >
40-
41- <dependency >
42- <groupId >junit</groupId >
43- <artifactId >junit</artifactId >
44- <scope >test</scope >
45- </dependency >
4640 </dependencies >
4741
4842 <build >
Original file line number Diff line number Diff line change 1+ package io .dongtai .iast .common .utils ;
2+
3+ import java .io .PrintWriter ;
4+ import java .io .StringWriter ;
5+
6+ /**
7+ * 处理异常相关的公共逻辑提取到这里
8+ *
9+ * @author CC11001100
10+ * @since 1.13.2
11+ */
12+ public class ExceptionUtil {
13+
14+ /**
15+ * 把printStackTrace会打印的内容以字符串的形式返回
16+ *
17+ * @param e
18+ * @return
19+ */
20+ public static String getPrintStackTraceString (Throwable e ) {
21+ StringWriter stringWriter = new StringWriter ();
22+ PrintWriter printWriter = new PrintWriter (stringWriter );
23+ e .printStackTrace (printWriter );
24+ return stringWriter .toString ();
25+ }
26+
27+ }
Original file line number Diff line number Diff line change 1+ package io .dongtai .iast .common .utils ;
2+
3+ import org .junit .Assert ;
4+ import org .junit .Test ;
5+
6+ import static org .junit .Assert .*;
7+
8+ /**
9+ * @author CC11001100
10+ */
11+ public class ExceptionUtilTest {
12+
13+ @ Test
14+ public void getPrintStackTraceString () {
15+ Exception e = new Exception ();
16+ String printStackTraceString = ExceptionUtil .getPrintStackTraceString (e );
17+ Assert .assertNotNull (printStackTraceString );
18+ }
19+
20+ }
Original file line number Diff line number Diff line change 145145 </build >
146146
147147 <dependencies >
148- <dependency >
149- <groupId >junit</groupId >
150- <artifactId >junit</artifactId >
151- <version >${junit.version} </version >
152- <scope >test</scope >
153- </dependency >
154148 <dependency >
155149 <groupId >io.dongtai.iast</groupId >
156150 <artifactId >dongtai-spy</artifactId >
Original file line number Diff line number Diff line change 3838 </plugins >
3939 </build >
4040
41- <dependencies >
42- <dependency >
43- <groupId >junit</groupId >
44- <artifactId >junit</artifactId >
45- <version >${junit.version} </version >
46- <scope >test</scope >
47- </dependency >
48- <dependency >
49- <groupId >org.openjdk.jmh</groupId >
50- <artifactId >jmh-core</artifactId >
51- <scope >test</scope >
52- </dependency >
53- <dependency >
54- <groupId >org.openjdk.jmh</groupId >
55- <artifactId >jmh-generator-annprocess</artifactId >
56- <scope >test</scope >
57- </dependency >
58- </dependencies >
59-
6041</project >
You can’t perform that action at this time.
0 commit comments