zhuyifan

fix

...@@ -56,7 +56,9 @@ public class MysqlZipkinInterceptor implements StatementInterceptorV2 { ...@@ -56,7 +56,9 @@ public class MysqlZipkinInterceptor implements StatementInterceptorV2 {
56 56
57 private Tracing getTracing() { 57 private Tracing getTracing() {
58 if (tracing == null) { 58 if (tracing == null) {
59 - tracing = AppConfig.APP_CONTEXT.getBean(Tracing.class); 59 + tracing = AppConfig.APP_CONTEXT != null
60 + ? AppConfig.APP_CONTEXT.getBean(Tracing.class)
61 + : null;
60 } 62 }
61 return tracing; 63 return tracing;
62 } 64 }
...@@ -70,6 +72,9 @@ public class MysqlZipkinInterceptor implements StatementInterceptorV2 { ...@@ -70,6 +72,9 @@ public class MysqlZipkinInterceptor implements StatementInterceptorV2 {
70 final Statement interceptedStatement, 72 final Statement interceptedStatement,
71 final Connection connection) throws SQLException { 73 final Connection connection) throws SQLException {
72 final var tracing = getTracing(); 74 final var tracing = getTracing();
75 + if (tracing == null) {
76 + return null;
77 + }
73 final var context = tracing.currentTraceContext().get(); 78 final var context = tracing.currentTraceContext().get();
74 final var sqlStr = sql != null ? sql : interceptedStatement.toString(); 79 final var sqlStr = sql != null ? sql : interceptedStatement.toString();
75 log.info("sql exec: {}", sqlStr.replace("\n", "")); 80 log.info("sql exec: {}", sqlStr.replace("\n", ""));
...@@ -110,6 +115,9 @@ public class MysqlZipkinInterceptor implements StatementInterceptorV2 { ...@@ -110,6 +115,9 @@ public class MysqlZipkinInterceptor implements StatementInterceptorV2 {
110 final boolean noGoodIndexUsed, 115 final boolean noGoodIndexUsed,
111 final SQLException statementException) throws SQLException { 116 final SQLException statementException) throws SQLException {
112 final var tracing = getTracing(); 117 final var tracing = getTracing();
118 + if (tracing == null) {
119 + return null;
120 + }
113 final var span = ThreadLocalSpan.CURRENT_TRACER.remove(); 121 final var span = ThreadLocalSpan.CURRENT_TRACER.remove();
114 if (statementException != null) { 122 if (statementException != null) {
115 log.error("sql exec failed", statementException); 123 log.error("sql exec failed", statementException);
......