Skip to content

Commit

Permalink
fix bug for java 9
Browse files Browse the repository at this point in the history
  • Loading branch information
chihuopub committed Apr 20, 2021
1 parent ef100f4 commit b2e486c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import net.bytebuddy.implementation.bytecode.assign.Assigner;
import net.bytebuddy.matcher.ElementMatcher;

import javax.sql.DataSource;
import java.sql.Connection;
import java.util.Map;
import java.util.function.Supplier;

Expand All @@ -42,8 +40,8 @@
public abstract class JdbcDataSourceAdvice implements Transformation {
@Override
public <T extends Definition> T define(Definition<T> def) {
return def.type(isSubTypeOf(DataSource.class))
.transform(getConnection(named("getConnection").and(returns(isSubTypeOf(Connection.class)))))
return def.type(hasSuperType(named("javax.sql.DataSource")))
.transform(getConnection(named("getConnection").and(returns(named("java.sql.Connection")))))
.end();
}

Expand All @@ -54,12 +52,12 @@ static class GetConnection extends AbstractAdvice {

@Injection.Autowire
GetConnection(AgentInterceptorChainInvoker chainInvoker,
@Injection.Qualifier("supplier4DataSourceGetCon")Supplier<AgentInterceptorChain.Builder> supplier) {
@Injection.Qualifier("supplier4DataSourceGetCon") Supplier<AgentInterceptorChain.Builder> supplier) {
super(supplier, chainInvoker);
}

@Advice.OnMethodEnter
ForwardLock.Release<Map<Object, Object>> enter(@Advice.This DataSource invoker,
ForwardLock.Release<Map<Object, Object>> enter(@Advice.This Object invoker,
@Advice.Origin("#m") String method,
@Advice.AllArguments Object[] args) {
return this.doEnter(invoker, method, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

import java.sql.Statement;
import java.util.Map;
import java.util.function.Supplier;

Expand All @@ -42,7 +41,7 @@
public abstract class JdbcStatementAdvice implements Transformation {
@Override
public <T extends Definition> T define(Definition<T> def) {
return def.type(isSubTypeOf(Statement.class).and(not(isInterface().or(isAbstract()))))
return def.type(hasSuperType(named("java.sql.Statement")).and(not(isInterface().or(isAbstract()))))
.transform(objConstruct(isConstructor(), AgentDynamicFieldAccessor.DYNAMIC_FIELD_NAME))
.transform(execute(nameStartsWith("execute")
.and(not(returns(TypeDescription.VOID)))
Expand Down

0 comments on commit b2e486c

Please sign in to comment.