Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SermantClassLoader设计咨询 #1595

Closed
JedrekWang opened this issue Aug 6, 2024 · 3 comments
Closed

SermantClassLoader设计咨询 #1595

JedrekWang opened this issue Aug 6, 2024 · 3 comments
Labels
kind/question Further information is requested

Comments

@JedrekWang
Copy link

What do you want to ask?

现状

我对比了Sermant和OpenTelemetry关于JavaAgent ClassLoader隔离这块的实现
发现一点差异:OpenTelemetry通过将AgentClassLoader的parent设置为null,AgentClassLoader先从自己的classpath加载,加载不到从BootStrapClassLoader加载,来隔离JavaAgent和业务代码
但是Sermant的SermantClassLoader的parent为AppClassLoader,先从自己的classpath加载,加载不到走双亲委托加载(BootStrapClassLoader -> ExtClassLoader -> AppClassLoader流程)

问题

麻烦咨询一下,SermantClassLoader为啥故意没有将parent设置为null,这样不是可以更好的隔离业务代码吗?还是说有基于其他考虑?感谢答复(应该不影响Sermant的PluginClassLoader,仍然可以通过localLoader机制直接获取宿主服务的类)

@JedrekWang JedrekWang added the kind/question Further information is requested label Aug 6, 2024
@Issues-translate-bot
Copy link

Detect the issue's language is not English and translate it automatically.


Title: SermantClassLoader design consultation

What do you want to ask?

status quo

I compared the implementation of JavaAgent ClassLoader isolation between Sermant and OpenTelemetry.
Found a little difference: OpenTelemetry isolates JavaAgent and business code by setting the parent of AgentClassLoader to null. AgentClassLoader is loaded from its own classpath first, and if it cannot be loaded, it is loaded from BootStrapClassLoader.
However, the parent of Sermant's SermantClassLoader is AppClassLoader. It is loaded from its own classpath first. If it cannot be loaded, the parent delegates the loading (BootStrapClassLoader -> ExtClassLoader -> AppClassLoader process).

question

Please ask, why does SermantClassLoader deliberately not set parent to null? Wouldn't this better isolate business code? Or is it based on other considerations? Thanks for the reply (it should not affect Sermant’s PluginClassLoader, you can still directly obtain the host service class through the localLoader mechanism)

@hanbingleixue
Copy link
Collaborator

@JedrekWang This is to reuse the classes that have been loaded by the host application, ensuring that the SermantClassLoader does not need to be reloaded.

@hanbingleixue
Copy link
Collaborator

Question answered. No follow-up questions. Therefore, this issue is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants