mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Remove lock around transform step
Closes gh-37199
This commit is contained in:
+30
-32
@@ -57,42 +57,40 @@ class ClassFileTransformerAdapter implements ClassFileTransformer {
|
||||
ClassLoader loader, String className, Class<?> classBeingRedefined,
|
||||
ProtectionDomain protectionDomain, byte[] classfileBuffer) {
|
||||
|
||||
synchronized (this) {
|
||||
if (this.currentlyTransforming.get() == Boolean.TRUE) {
|
||||
// Defensively back out when called from within the transform delegate below:
|
||||
// in particular, for the over-eager transformer implementation in Hibernate.
|
||||
return null;
|
||||
}
|
||||
if (this.currentlyTransforming.get() == Boolean.TRUE) {
|
||||
// Defensively back out when called from within the transform delegate below:
|
||||
// in particular, for the over-eager transformer implementation in Hibernate.
|
||||
return null;
|
||||
}
|
||||
|
||||
this.currentlyTransforming.set(Boolean.TRUE);
|
||||
try {
|
||||
byte[] transformed = this.classTransformer.transform(
|
||||
loader, className, classBeingRedefined, protectionDomain, classfileBuffer);
|
||||
if (transformed != null && logger.isDebugEnabled()) {
|
||||
logger.debug("Transformer of class [" + this.classTransformer.getClass().getName() +
|
||||
"] transformed class [" + className + "]; bytes in=" +
|
||||
classfileBuffer.length + "; bytes out=" + transformed.length);
|
||||
}
|
||||
return transformed;
|
||||
this.currentlyTransforming.set(Boolean.TRUE);
|
||||
try {
|
||||
byte[] transformed = this.classTransformer.transform(
|
||||
loader, className, classBeingRedefined, protectionDomain, classfileBuffer);
|
||||
if (transformed != null && logger.isDebugEnabled()) {
|
||||
logger.debug("Transformer of class [" + this.classTransformer.getClass().getName() +
|
||||
"] transformed class [" + className + "]; bytes in=" +
|
||||
classfileBuffer.length + "; bytes out=" + transformed.length);
|
||||
}
|
||||
catch (ClassCircularityError ex) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error("Circularity error while weaving class [" + className + "] with " +
|
||||
"transformer of class [" + this.classTransformer.getClass().getName() + "]", ex);
|
||||
}
|
||||
throw new IllegalStateException("Failed to weave class [" + className + "]", ex);
|
||||
return transformed;
|
||||
}
|
||||
catch (ClassCircularityError ex) {
|
||||
if (logger.isErrorEnabled()) {
|
||||
logger.error("Circularity error while weaving class [" + className + "] with " +
|
||||
"transformer of class [" + this.classTransformer.getClass().getName() + "]", ex);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Error weaving class [" + className + "] with transformer of class [" +
|
||||
this.classTransformer.getClass().getName() + "]", ex);
|
||||
}
|
||||
// The exception will be ignored by the class loader, anyway...
|
||||
throw new IllegalStateException("Could not weave class [" + className + "]", ex);
|
||||
}
|
||||
finally {
|
||||
this.currentlyTransforming.remove();
|
||||
throw new IllegalStateException("Failed to weave class [" + className + "]", ex);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("Error weaving class [" + className + "] with transformer of class [" +
|
||||
this.classTransformer.getClass().getName() + "]", ex);
|
||||
}
|
||||
// The exception will be ignored by the class loader, anyway...
|
||||
throw new IllegalStateException("Could not weave class [" + className + "]", ex);
|
||||
}
|
||||
finally {
|
||||
this.currentlyTransforming.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user