This is an automated email from the ASF dual-hosted git repository.

jamesfredley pushed a commit to branch bridge-backward-compat-shims
in repository https://gitbox.apache.org/repos/asf/grails-core.git


The following commit(s) were added to refs/heads/bridge-backward-compat-shims 
by this push:
     new ccc0173178 Fix bridge shim issues from code review
ccc0173178 is described below

commit ccc01731785cccf65c49e2539b14a5ed6964c89a
Author: James Fredley <[email protected]>
AuthorDate: Thu Mar 12 20:32:18 2026 -0400

    Fix bridge shim issues from code review
    
    - GrailsApplicationPostProcessor: resolve discovery from context via
      containsBean(BEAN_NAME) before falling back to new instance, avoiding
      duplicate DefaultGrailsPluginDiscovery creation
    - DefaultGrailsPluginManager: forward deprecated constructor arguments
      to matching DefaultGrailsPluginDiscovery constructors instead of
      discarding them with the no-arg constructor
    - CorePluginFinder: remove ParentApplicationContextAware interface that
      the original class never implemented; Spring would call
      setParentApplicationContext and hit the UnsupportedOperationException
    
    Assisted-by: Claude Code <[email protected]>
---
 .../boot/config/GrailsApplicationPostProcessor.groovy  | 16 ++++++++++++++--
 .../grails/plugins/DefaultGrailsPluginManager.java     | 18 +++++++++---------
 .../groovy/org/grails/plugins/CorePluginFinder.java    | 14 +-------------
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git 
a/grails-core/src/main/groovy/grails/boot/config/GrailsApplicationPostProcessor.groovy
 
b/grails-core/src/main/groovy/grails/boot/config/GrailsApplicationPostProcessor.groovy
index b5cba7f1c8..298ffc5bde 100644
--- 
a/grails-core/src/main/groovy/grails/boot/config/GrailsApplicationPostProcessor.groovy
+++ 
b/grails-core/src/main/groovy/grails/boot/config/GrailsApplicationPostProcessor.groovy
@@ -100,12 +100,24 @@ class GrailsApplicationPostProcessor implements 
BeanDefinitionRegistryPostProces
 
     /**
      * @deprecated Use {@link 
#GrailsApplicationPostProcessor(GrailsApplicationLifeCycle, ApplicationContext, 
GrailsPluginDiscovery, Class[])} instead.
-     * Plugin discovery is now provided explicitly. This constructor creates a 
default discovery instance.
+     * Plugin discovery is resolved from the application context when 
available, otherwise a default instance is created.
      * Will be removed in Grails 8.0.0.
      */
     @Deprecated(forRemoval = true, since = "7.1")
     GrailsApplicationPostProcessor(GrailsApplicationLifeCycle lifeCycle, 
ApplicationContext applicationContext, Class...classes) {
-        this(lifeCycle, applicationContext, new 
org.apache.grails.core.plugins.DefaultGrailsPluginDiscovery(), classes)
+        this(lifeCycle, applicationContext, 
resolvePluginDiscovery(applicationContext), classes)
+    }
+
+    /**
+     * Resolves the {@link GrailsPluginDiscovery} from the application context 
if available,
+     * otherwise creates a new default instance. The bootstrap registry 
promotes the discovery
+     * bean before context refresh, so it is safe to look up by bean name at 
this stage.
+     */
+    private static GrailsPluginDiscovery 
resolvePluginDiscovery(ApplicationContext applicationContext) {
+        if (applicationContext != null && 
applicationContext.containsBean(GrailsPluginDiscovery.BEAN_NAME)) {
+            return (GrailsPluginDiscovery) 
applicationContext.getBean(GrailsPluginDiscovery.BEAN_NAME)
+        }
+        return new 
org.apache.grails.core.plugins.DefaultGrailsPluginDiscovery()
     }
 
     /**
diff --git 
a/grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java 
b/grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java
index 86d292805e..7dc2d3adec 100644
--- a/grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java
+++ b/grails-core/src/main/groovy/grails/plugins/DefaultGrailsPluginManager.java
@@ -96,32 +96,32 @@ public class DefaultGrailsPluginManager extends 
AbstractGrailsPluginManager {
 
     /**
      * @deprecated Use {@link #DefaultGrailsPluginManager(GrailsApplication, 
GrailsPluginDiscovery)} instead.
-     * Plugin discovery is now handled by {@link GrailsPluginDiscovery}. This 
constructor creates a default
-     * discovery instance. Will be removed in Grails 8.0.0.
+     * Plugin discovery is now handled by {@link GrailsPluginDiscovery}. This 
constructor forwards
+     * the resource path to the discovery instance. Will be removed in Grails 
8.0.0.
      */
     @Deprecated(forRemoval = true, since = "7.1")
     public DefaultGrailsPluginManager(String resourcePath, GrailsApplication 
application) {
-        this(application, new DefaultGrailsPluginDiscovery());
+        this(application, new DefaultGrailsPluginDiscovery(resourcePath));
     }
 
     /**
      * @deprecated Use {@link #DefaultGrailsPluginManager(GrailsApplication, 
GrailsPluginDiscovery)} instead.
-     * Plugin discovery is now handled by {@link GrailsPluginDiscovery}. This 
constructor creates a default
-     * discovery instance. Will be removed in Grails 8.0.0.
+     * Plugin discovery is now handled by {@link GrailsPluginDiscovery}. This 
constructor forwards
+     * the plugin resources to the discovery instance. Will be removed in 
Grails 8.0.0.
      */
     @Deprecated(forRemoval = true, since = "7.1")
     public DefaultGrailsPluginManager(String[] pluginResources, 
GrailsApplication application) {
-        this(application, new DefaultGrailsPluginDiscovery());
+        this(application, new DefaultGrailsPluginDiscovery(pluginResources));
     }
 
     /**
      * @deprecated Use {@link #DefaultGrailsPluginManager(GrailsApplication, 
GrailsPluginDiscovery)} instead.
-     * Plugin discovery is now handled by {@link GrailsPluginDiscovery}. This 
constructor creates a default
-     * discovery instance. Will be removed in Grails 8.0.0.
+     * Plugin discovery is now handled by {@link GrailsPluginDiscovery}. This 
constructor forwards
+     * the plugin classes to the discovery instance. Will be removed in Grails 
8.0.0.
      */
     @Deprecated(forRemoval = true, since = "7.1")
     public DefaultGrailsPluginManager(Class<?>[] plugins, GrailsApplication 
application) {
-        this(application, new DefaultGrailsPluginDiscovery());
+        this(application, new DefaultGrailsPluginDiscovery(plugins));
     }
 
     public GrailsPlugin[] getUserPlugins() {
diff --git 
a/grails-core/src/main/groovy/org/grails/plugins/CorePluginFinder.java 
b/grails-core/src/main/groovy/org/grails/plugins/CorePluginFinder.java
index 0af1176e4b..b548ac209d 100644
--- a/grails-core/src/main/groovy/org/grails/plugins/CorePluginFinder.java
+++ b/grails-core/src/main/groovy/org/grails/plugins/CorePluginFinder.java
@@ -18,17 +18,14 @@
  */
 package org.grails.plugins;
 
-import org.springframework.context.ApplicationContext;
-
 import grails.core.GrailsApplication;
-import grails.core.support.ParentApplicationContextAware;
 
 /**
  * @deprecated Plugin discovery is now handled by {@link 
org.apache.grails.core.plugins.GrailsPluginDiscovery}.
  * This compatibility stub will be removed in Grails 8.0.0.
  */
 @Deprecated(forRemoval = true, since = "7.1")
-public class CorePluginFinder implements ParentApplicationContextAware {
+public class CorePluginFinder {
 
     public static final String CORE_PLUGIN_PATTERN = 
"META-INF/grails-plugin.xml";
 
@@ -56,13 +53,4 @@ public class CorePluginFinder implements 
ParentApplicationContextAware {
     public BinaryGrailsPluginDescriptor getBinaryDescriptor(Class<?> 
pluginClass) {
         throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
     }
-
-    /**
-     * @deprecated Use {@link 
org.apache.grails.core.plugins.GrailsPluginDiscovery} instead.
-     */
-    @Deprecated(forRemoval = true, since = "7.1")
-    @Override
-    public void setParentApplicationContext(ApplicationContext parent) {
-        throw new UnsupportedOperationException(UNSUPPORTED_MESSAGE);
-    }
 }

Reply via email to