Browse Source

SpringPersistenceUnitInfo leniently ignores transformer if no LoadTimeWeaver is present

Closes gh-29736
pull/29766/head
Juergen Hoeller 3 years ago
parent
commit
42b16591ec
  1. 11
      spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/SpringPersistenceUnitInfo.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
package org.springframework.orm.jpa.persistenceunit;
import jakarta.persistence.spi.ClassTransformer;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.DecoratingClassLoader;
import org.springframework.instrument.classloading.LoadTimeWeaver;
@ -79,10 +80,12 @@ class SpringPersistenceUnitInfo extends MutablePersistenceUnitInfo { @@ -79,10 +80,12 @@ class SpringPersistenceUnitInfo extends MutablePersistenceUnitInfo {
*/
@Override
public void addTransformer(ClassTransformer classTransformer) {
if (this.loadTimeWeaver == null) {
throw new IllegalStateException("Cannot apply class transformer without LoadTimeWeaver specified");
if (this.loadTimeWeaver != null) {
this.loadTimeWeaver.addTransformer(new ClassFileTransformerAdapter(classTransformer));
}
else {
LogFactory.getLog(getClass()).info("No LoadTimeWeaver setup: ignoring JPA class transformer");
}
this.loadTimeWeaver.addTransformer(new ClassFileTransformerAdapter(classTransformer));
}
/**

Loading…
Cancel
Save