borinquenkid commented on code in PR #15568:
URL: https://github.com/apache/grails-core/pull/15568#discussion_r3453999134
##########
grails-data-hibernate7/grails-plugin/src/main/groovy/grails/test/hibernate/HibernateSpec.groovy:
##########
@@ -56,36 +74,124 @@ abstract class HibernateSpec extends Specification {
@Shared @AutoCleanup HibernateDatastore hibernateDatastore
@Shared PlatformTransactionManager transactionManager
+ @Shared HibernateProxyHandler proxyHandler = new HibernateProxyHandler()
+ @Shared @AutoCleanup('close') ApplicationContext applicationContext
- void setupSpec() {
+ static class TestGrailsBytecodeProvider extends GrailsBytecodeProvider {
- List<PropertySourceLoader> propertySourceLoaders =
SpringFactoriesLoader.loadFactories(PropertySourceLoader,
getClass().getClassLoader())
- ResourceLoader resourceLoader = new DefaultResourceLoader()
- MutablePropertySources propertySources = new MutablePropertySources()
- PropertySourceLoader ymlLoader = propertySourceLoaders.find {
it.getFileExtensions().toList().contains('yml') }
- if (ymlLoader) {
- load(resourceLoader, ymlLoader, 'application.yml').each {
- propertySources.addLast(it)
- }
- }
- PropertySourceLoader groovyLoader = propertySourceLoaders.find {
it.getFileExtensions().toList().contains('groovy') }
- if (groovyLoader) {
- load(resourceLoader, groovyLoader, 'application.groovy').each {
- propertySources.addLast(it)
+ @Override
+ @CompileStatic(TypeCheckingMode.SKIP)
+ protected ByteBuddyProxyHelper createProxyHelper() {
+ try {
+ def byteBuddyStateClass =
Class.forName('org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState')
+ def byteBuddyStateConstructor =
byteBuddyStateClass.getDeclaredConstructor()
+ byteBuddyStateConstructor.setAccessible(true)
+ def byteBuddyState = byteBuddyStateConstructor.newInstance()
+ return new ByteBuddyProxyHelper(byteBuddyState as
org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState)
+ } catch (e) {
Review Comment:
Removed — `TestGrailsBytecodeProvider` was overriding `createProxyHelper()`
via reflection to produce exactly what `GrailsBytecodeProvider` already does
directly. Replaced with `GrailsBytecodeProvider` wired straight into the bean
definition. As for the `internal` package concern: `ByteBuddyState` is used
directly in `GrailsBytecodeProvider` itself — Hibernate exposes no public
alternative.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]