SpringPersistenceUnitInfo leniently ignores transformer if no LoadTimeWeaver is present
Closes gh-29736
This commit is contained in:
parent
62cf2f0a4f
commit
42b16591ec
|
@ -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 @@
|
|||
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 {
|
|||
*/
|
||||
@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…
Reference in New Issue