admin管理员组文章数量:1307167
Our Spring Boot application modifies classes by adding certain annotations (annotateType(...)) with ByteBuddy. For example:
private DynamicType.Loaded<? extends MyClassToRedefine> getLoadedTypeOfResource() {
if (myClassToRedefineImplLoadedType == null) {
try (var unloadedResource = new ByteBuddy()
.subclass(MyClassToRedefine.class)
.annotateType(newAnnotation1)
.annotateType(newAnnotation2)
.annotateType(newAnnotation3)
.make()) {
myClassToRedefineImplLoadedType = unloadedResource.load(ClassLoader.getSystemClassLoader());
}
}
return myClassToRedefineImplLoadedType;
}
The Spring Boot tests already have @DirtiesContext. They run fine individually.
However, when run together I notice that the annotations stay the same between tests which causes issues. The root cause is that ByteBuddy modifies classes at the JVM level, and those modifications persist across multiple test runs.
How can I clear/reset all modifications between tests?
EDIT: used annotations in test:
@SpringBootTest(properties = "spring.main.allow-bean-definition-overriding=true")
@EnableKubeAPIServer(updateKubeConfigFile = true)
@DirtiesContext
本文标签: javaReset ByteBuddy modified classes between Spring Boot integration testsStack Overflow
版权声明:本文标题:java - Reset ByteBuddy modified classes between Spring Boot integration tests - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741826992a2399705.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论