Support default database(not set through JDBC URL) in mysql-5.x plugin (#154)
This commit is contained in:
parent
a5ccbca693
commit
46d99c5d69
|
|
@ -37,6 +37,7 @@ Release Notes.
|
|||
* Fix the bug that maybe causing memory leak and repeated traceId when use gateway-2.1.x-plugin or gateway-3.x-plugin.
|
||||
* Fix Grpc 1.x plugin could leak context due to gRPC cancelled.
|
||||
* Add JDK ThreadPoolExecutor Plugin.
|
||||
* Support default database(not set through JDBC URL) in mysql-5.x plugin.
|
||||
|
||||
#### Documentation
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.skywalking.apm.plugin.jdbc.mysql.v5;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor;
|
||||
|
|
@ -42,7 +43,8 @@ public class ConnectionCreate5xInterceptor implements StaticMethodsAroundInterce
|
|||
public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes,
|
||||
Object ret) {
|
||||
if (ret instanceof EnhancedInstance) {
|
||||
ConnectionInfo connectionInfo = ConnectionCache.get(allArguments[0].toString(), allArguments[1].toString(), allArguments[3].toString());
|
||||
String database = Objects.isNull(allArguments[3]) ? "" : allArguments[3].toString();
|
||||
ConnectionInfo connectionInfo = ConnectionCache.get(allArguments[0].toString(), allArguments[1].toString(), database);
|
||||
if (connectionInfo == null) {
|
||||
connectionInfo = URLParser.parser(allArguments[4].toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,4 +51,16 @@ public class ConnectionImplCreateInterceptorTest {
|
|||
}, null, objectInstance);
|
||||
verify(objectInstance).setSkyWalkingDynamicField(Matchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultIsEnhanceInstanceWithNoDatabase() throws Throwable {
|
||||
interceptor.afterMethod(null, null, new Object[] {
|
||||
"localhost",
|
||||
3360,
|
||||
null,
|
||||
null,
|
||||
"jdbc:mysql:replication://localhost:3360,localhost:3360,localhost:3360/test?useUnicode=true&characterEncoding=utf8&useSSL=false&roundRobinLoadBalance=true"
|
||||
}, null, objectInstance);
|
||||
verify(objectInstance).setSkyWalkingDynamicField(Matchers.any());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue