GithubHelp home page GithubHelp logo

Publish blocking about byte-buddy HOT 12 OPEN

SongTing0711 avatar SongTing0711 commented on August 19, 2024
Publish blocking

from byte-buddy.

Comments (12)

raphw avatar raphw commented on August 19, 2024

Did you take a thread dump? Maybe you intercept a method and invoke the proxy again? Or you lock the same object from different threads.

from byte-buddy.

SongTing0711 avatar SongTing0711 commented on August 19, 2024

Did you take a thread dump? Maybe you intercept a method and invoke the proxy again? Or you lock the same object from different threads.

Perhaps so, I tried to configure the class that was not enhanced, and the result was successful. However, this is not safe. I tried the following code again, hoping to block the classes that have already been enhanced by cglib, but it still hasn't been blocked
why?
private static class InnerTransformer implements AgentBuilder.Transformer {
@OverRide
public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription,
ClassLoader classLoader, JavaModule module, ProtectionDomain protectionDomain) {
return builder.visit(Advice.to(MethodServiceAdvice.class)
.on(ElementMatchers.not(ElementMatchers.isConstructor())
.and(ElementMatchers
.noneOf(ElementMatchers.hasSuperType(ElementMatchers.named("StaticApplicationContext"))))
.and(ElementMatchers.not(ElementMatchers.isTypeInitializer()))
.and(ElementMatchers.not(ElementMatchers.isSetter()))
.and(ElementMatchers.not(ElementMatchers.isGetter()))
.and(ElementMatchers.not(ElementMatchers.nameStartsWith("net.bytebuddy.generated")))
.and(ElementMatchers.not(ElementMatchers.nameContains("EnhancerBySpringCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("$$")))
.and(ElementMatchers.not(ElementMatchers.nameContains("FastClassByCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("MethodInterceptor")))));
}
}

from byte-buddy.

SongTing0711 avatar SongTing0711 commented on August 19, 2024

take a thread dump

I tried to take a thread dump, but the PID of tomcat kept changing, so I couldn't get it

from byte-buddy.

raphw avatar raphw commented on August 19, 2024

You can use jps to find it.

from byte-buddy.

SongTing0711 avatar SongTing0711 commented on August 19, 2024

You can use jps to find it.
I used JPS, but you can see that the displayed PID keeps changing

image

from byte-buddy.

SongTing0711 avatar SongTing0711 commented on August 19, 2024

You can use jps to find it.
I used JPS, but you can see that the displayed PID keeps changing

image

Can you take a look at why the filtering above doesn't work

private static class InnerTransformer implements AgentBuilder.Transformer {
@OverRide
public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription,
ClassLoader classLoader, JavaModule module, ProtectionDomain protectionDomain) {
return builder.visit(Advice.to(MethodServiceAdvice.class)
.on(ElementMatchers.not(ElementMatchers.isConstructor())
.and(ElementMatchers
.noneOf(ElementMatchers.hasSuperType(ElementMatchers.named("StaticApplicationContext"))))
.and(ElementMatchers.not(ElementMatchers.isTypeInitializer()))
.and(ElementMatchers.not(ElementMatchers.isSetter()))
.and(ElementMatchers.not(ElementMatchers.isGetter()))
.and(ElementMatchers.not(ElementMatchers.nameStartsWith("net.bytebuddy.generated")))
.and(ElementMatchers.not(ElementMatchers.nameContains("EnhancerBySpringCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("$$")))
.and(ElementMatchers.not(ElementMatchers.nameContains("FastClassByCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("MethodInterceptor")))));
}
}

from byte-buddy.

SongTing0711 avatar SongTing0711 commented on August 19, 2024

I used JPS, but you can see that the displayed PID keeps changing
image

from byte-buddy.

raphw avatar raphw commented on August 19, 2024

Are those processes short lived? If so, it's hard to hit a target. Maybe you should change JAVA_TOOL_OPTIONS to add your agent when any Java process is starting up?

from byte-buddy.

SongTing0711 avatar SongTing0711 commented on August 19, 2024

Can you take a look at why the filtering above doesn't work

private static class InnerTransformer implements AgentBuilder.Transformer {
@OverRide
public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription,
ClassLoader classLoader, JavaModule module, ProtectionDomain protectionDomain) {
return builder.visit(Advice.to(MethodServiceAdvice.class)
.on(ElementMatchers.not(ElementMatchers.isConstructor())
.and(ElementMatchers
.noneOf(ElementMatchers.hasSuperType(ElementMatchers.named("StaticApplicationContext"))))
.and(ElementMatchers.not(ElementMatchers.isTypeInitializer()))
.and(ElementMatchers.not(ElementMatchers.isSetter()))
.and(ElementMatchers.not(ElementMatchers.isGetter()))
.and(ElementMatchers.not(ElementMatchers.nameStartsWith("net.bytebuddy.generated")))
.and(ElementMatchers.not(ElementMatchers.nameContains("EnhancerBySpringCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("$$")))
.and(ElementMatchers.not(ElementMatchers.nameContains("FastClassByCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("MethodInterceptor")))));
}
}

from byte-buddy.

raphw avatar raphw commented on August 19, 2024

What filtering do you mean?

from byte-buddy.

SongTing0711 avatar SongTing0711 commented on August 19, 2024

What I mean is that based on the previous investigation, it seems that the classes enhanced by cglib have been enhanced again by bytebuddy.
Therefore, I want to use the ElementMatchers provided by bytebuddy to filter all the classes enhanced by cglib,
which is this code, but it still cannot be successfully filtered
private static class InnerTransformer implements AgentBuilder.Transformer {
@OverRide
public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription,
ClassLoader classLoader, JavaModule module, ProtectionDomain protectionDomain) {
return builder.visit(Advice.to(MethodServiceAdvice.class)
.on(ElementMatchers.not(ElementMatchers.isConstructor())
.and(ElementMatchers
.noneOf(ElementMatchers.hasSuperType(ElementMatchers.named("StaticApplicationContext"))))
.and(ElementMatchers.not(ElementMatchers.isTypeInitializer()))
.and(ElementMatchers.not(ElementMatchers.isSetter()))
.and(ElementMatchers.not(ElementMatchers.isGetter()))
.and(ElementMatchers.not(ElementMatchers.nameStartsWith("net.bytebuddy.generated")))
.and(ElementMatchers.not(ElementMatchers.nameContains("EnhancerBySpringCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("$$")))
.and(ElementMatchers.not(ElementMatchers.nameContains("FastClassByCGLIB")))
.and(ElementMatchers.not(ElementMatchers.nameContains("MethodInterceptor")))));
}
}

from byte-buddy.

raphw avatar raphw commented on August 19, 2024

You combine all these matchers. You likely want to use .or which implies that any condition holds.

from byte-buddy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.