Skip to content

Commit 42b1659

Browse files
committed
SpringPersistenceUnitInfo leniently ignores transformer if no LoadTimeWeaver is present
Closes gh-29736
1 parent 62cf2f0 commit 42b1659

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/SpringPersistenceUnitInfo.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package org.springframework.orm.jpa.persistenceunit;
1818

1919
import jakarta.persistence.spi.ClassTransformer;
20+
import org.apache.commons.logging.LogFactory;
2021

2122
import org.springframework.core.DecoratingClassLoader;
2223
import org.springframework.instrument.classloading.LoadTimeWeaver;
@@ -79,10 +80,12 @@ public ClassLoader getClassLoader() {
7980
*/
8081
@Override
8182
public void addTransformer(ClassTransformer classTransformer) {
82-
if (this.loadTimeWeaver == null) {
83-
throw new IllegalStateException("Cannot apply class transformer without LoadTimeWeaver specified");
83+
if (this.loadTimeWeaver != null) {
84+
this.loadTimeWeaver.addTransformer(new ClassFileTransformerAdapter(classTransformer));
85+
}
86+
else {
87+
LogFactory.getLog(getClass()).info("No LoadTimeWeaver setup: ignoring JPA class transformer");
8488
}
85-
this.loadTimeWeaver.addTransformer(new ClassFileTransformerAdapter(classTransformer));
8689
}
8790

8891
/**

0 commit comments

Comments
 (0)