未验证 提交 1297d2e1 编写于 作者: R raybi-asus 提交者: GitHub

Add null-conditional operators on these 3 files (#6007)

* add null conditional operators on these 3 files . To aviod some agent exception of Oracle jdbc.

* Add a line in Java Agent section of CHANGES.md file
Co-authored-by: wu-sheng's avatar吴晟 Wu Sheng <wu.sheng@foxmail.com>
上级 08b31adf
...@@ -13,6 +13,7 @@ Release Notes. ...@@ -13,6 +13,7 @@ Release Notes.
* Fix jdk-http and okhttp-3.x plugin did not overwrite the old trace header. * Fix jdk-http and okhttp-3.x plugin did not overwrite the old trace header.
* Support collecting logs of log4j, log4j2, and logback in the tracing context with a new `logger-plugin`. * Support collecting logs of log4j, log4j2, and logback in the tracing context with a new `logger-plugin`.
* Fix the unexpected RunningContext recreation in the Tomcat plugin. * Fix the unexpected RunningContext recreation in the Tomcat plugin.
* Fix the potential NPE when trace_sql_parameters is enabled.
#### OAP-Backend #### OAP-Backend
* Make meter receiver support MAL. * Make meter receiver support MAL.
......
...@@ -31,8 +31,10 @@ public class JDBCPreparedStatementIgnorableSetterInterceptor implements Instance ...@@ -31,8 +31,10 @@ public class JDBCPreparedStatementIgnorableSetterInterceptor implements Instance
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
final StatementEnhanceInfos statementEnhanceInfos = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField(); final StatementEnhanceInfos statementEnhanceInfos = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
final int index = (Integer) allArguments[0]; if (statementEnhanceInfos != null) {
statementEnhanceInfos.setParameter(index, Constants.SQL_PARAMETER_PLACEHOLDER); final int index = (Integer) allArguments[0];
statementEnhanceInfos.setParameter(index, Constants.SQL_PARAMETER_PLACEHOLDER);
}
} }
@Override @Override
......
...@@ -30,8 +30,10 @@ public class JDBCPreparedStatementNullSetterInterceptor implements InstanceMetho ...@@ -30,8 +30,10 @@ public class JDBCPreparedStatementNullSetterInterceptor implements InstanceMetho
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
final StatementEnhanceInfos statementEnhanceInfos = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField(); final StatementEnhanceInfos statementEnhanceInfos = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
final int index = (Integer) allArguments[0]; if (statementEnhanceInfos != null) {
statementEnhanceInfos.setParameter(index, "NULL"); final int index = (Integer) allArguments[0];
statementEnhanceInfos.setParameter(index, "NULL");
}
} }
@Override @Override
......
...@@ -30,9 +30,11 @@ public class JDBCPreparedStatementSetterInterceptor implements InstanceMethodsAr ...@@ -30,9 +30,11 @@ public class JDBCPreparedStatementSetterInterceptor implements InstanceMethodsAr
public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
final StatementEnhanceInfos statementEnhanceInfos = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField(); final StatementEnhanceInfos statementEnhanceInfos = (StatementEnhanceInfos) objInst.getSkyWalkingDynamicField();
final int index = (Integer) allArguments[0]; if (statementEnhanceInfos != null) {
final Object parameter = allArguments[1]; final int index = (Integer) allArguments[0];
statementEnhanceInfos.setParameter(index, parameter); final Object parameter = allArguments[1];
statementEnhanceInfos.setParameter(index, parameter);
}
} }
@Override @Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册