diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/ClassFileTransformerAdapter.java b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/ClassFileTransformerAdapter.java index 46b56d5364d..3f95f2d4681 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/ClassFileTransformerAdapter.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/ClassFileTransformerAdapter.java @@ -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(); } }