codeconsole commented on code in PR #15994:
URL: https://github.com/apache/grails-core/pull/15994#discussion_r3608818038


##########
grails-testing-support-core/src/main/groovy/org/grails/testing/GrailsUnitTest.groovy:
##########
@@ -118,6 +131,15 @@ trait GrailsUnitTest {
             }
         } catch (NoSuchMethodException e) {}
 
+        try {
+            Method beanRegistrarMethod = clazz.getMethod('beanRegistrar')
+            BeanRegistrar registrar = (BeanRegistrar) 
beanRegistrarMethod.invoke(plugin)
+            if (registrar != null) {
+                defineBeans(registrar)
+                return

Review Comment:
   Fixed in fc6ac88995. `defineBeans(Object plugin)` now applies the 
`doWithSpring()` DSL first and the `beanRegistrar()` second, no early returns — 
matching the boot order, with registrar beans winning name conflicts. Covered 
by the new `DefineBeansPluginHooksSpec`.



##########
grails-cache/src/main/groovy/grails/plugin/cache/GrailsCacheAutoConfiguration.groovy:
##########
@@ -0,0 +1,66 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.plugin.cache
+
+import groovy.transform.CompileStatic
+
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.boot.autoconfigure.AutoConfiguration
+import 
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
+import org.springframework.context.annotation.Bean
+
+import org.grails.plugin.cache.GrailsCacheManager
+
+/**
+ * Auto-configures the cache plugin's default cache manager and key generator. 
Registered here
+ * rather than by the plugin descriptor so that a bean contributed by the 
application or another
+ * plugin — for example a cache-provider plugin's {@code grailsCacheManager} — 
makes the default
+ * back off cleanly instead of triggering a bean-definition override.
+ *
+ * @since 8.0
+ */
+@AutoConfiguration
+@ConditionalOnProperty(name = 'grails.cache.enabled', matchIfMissing = true)
+@CompileStatic
+class GrailsCacheAutoConfiguration {
+
+    @Value('${grails.cache.cacheManager:}')
+    String cacheManagerType
+
+    @Bean
+    @ConditionalOnMissingBean(name = 'customCacheKeyGenerator')
+    CustomCacheKeyGenerator customCacheKeyGenerator() {
+        new CustomCacheKeyGenerator()
+    }
+
+    @Bean
+    @ConditionalOnMissingBean(name = 'grailsCacheManager')
+    GrailsCacheManager grailsCacheManager(CachePluginConfiguration 
grailsCacheConfiguration) {

Review Comment:
   Fixed in fc6ac88995. Added class-level 
`@ConditionalOnBean(CachePluginConfiguration)` so the auto-configuration backs 
off entirely when the plugin is not active; covers `customCacheKeyGenerator` 
too. Spec test added.



##########
grails-redis/src/main/groovy/grails/plugins/redis/util/RedisConfigurationUtil.groovy:
##########
@@ -99,6 +92,84 @@ class RedisConfigurationUtil {
         }
     }
 
+    /**
+     * Registers the pool-config, pool and service bean definitions for a 
redis connection
+     * directly against a {@link BeanDefinitionRegistry}, mirroring the beans 
the
+     * {@link #configureService} closure wires through the bean builder DSL. 
Used by the redis
+     * plugin's {@code beanRegistrar()}-registered post-processor.
+     */
+    static void configureService(BeanDefinitionRegistry registry, def 
redisConfigMap, String key, Class serviceClass) {

Review Comment:
   Fixed in fc6ac88995. The registry variant now skips `redisPoolConfig*`, 
`redisPool*` and `redisService*` names that already have definitions, so 
existing definitions win as in the other post-processors. Spec test added.



-- 
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]

Reply via email to