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

jamesfredley pushed a commit to branch fix/undertow-jboss-threads-java25
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 7244c0db675744ee70e873843bbdcc934ba105a9
Author: James Fredley <[email protected]>
AuthorDate: Fri Feb 20 20:16:23 2026 -0500

    fix: add jboss-threads 3.9.2 to Undertow feature for Java 25 compatibility
    
    When Undertow is selected as the servlet container, undertow-core
    transitively pulls in jboss-threads 3.7.0 which calls the terminally
    deprecated sun.misc.Unsafe::objectFieldOffset in its static initializer,
    producing a warning on Java 25. Pin jboss-threads to 3.9.2 as a
    runtimeOnly dependency to resolve this.
    
    Assisted-by: Claude Code <[email protected]>
---
 .../forge/feature/spring/SpringBootUndertowFeature.java    |  6 ++++++
 grails-forge/grails-forge-core/src/main/resources/pom.xml  |  6 ++++++
 .../org/grails/forge/feature/spring/SpringBootSpec.groovy  | 14 ++++++++++++++
 3 files changed, 26 insertions(+)

diff --git 
a/grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/spring/SpringBootUndertowFeature.java
 
b/grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/spring/SpringBootUndertowFeature.java
index cf78a00143..f9090e795e 100644
--- 
a/grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/spring/SpringBootUndertowFeature.java
+++ 
b/grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/spring/SpringBootUndertowFeature.java
@@ -54,6 +54,12 @@ public class SpringBootUndertowFeature extends 
SpringBootEmbeddedServlet {
                 .groupId("org.springframework.boot")
                 .artifactId("spring-boot-starter-undertow")
                 .implementation());
+        // Force jboss-threads to 3.9.2 to fix 
sun.misc.Unsafe::objectFieldOffset warning on Java 25.
+        // undertow-core pulls in 3.7.0 which calls the terminally deprecated 
API in its static initializer.
+        generatorContext.addDependency(Dependency.builder()
+                .groupId("org.jboss.threads")
+                .lookupArtifactId("jboss-threads")
+                .runtimeOnly());
     }
 
     @Override
diff --git a/grails-forge/grails-forge-core/src/main/resources/pom.xml 
b/grails-forge/grails-forge-core/src/main/resources/pom.xml
index 8b81f55d2f..e8d3d09e44 100644
--- a/grails-forge/grails-forge-core/src/main/resources/pom.xml
+++ b/grails-forge/grails-forge-core/src/main/resources/pom.xml
@@ -74,5 +74,11 @@
             <artifactId>gradle-jrebel-plugin</artifactId>
             <version>1.2.1</version>
         </dependency>
+        <dependency>
+            <!-- Force newer version to fix sun.misc.Unsafe::objectFieldOffset 
warning on Java 25 -->
+            <groupId>org.jboss.threads</groupId>
+            <artifactId>jboss-threads</artifactId>
+            <version>3.9.2</version>
+        </dependency>
     </dependencies>
 </project>
diff --git 
a/grails-forge/grails-forge-core/src/test/groovy/org/grails/forge/feature/spring/SpringBootSpec.groovy
 
b/grails-forge/grails-forge-core/src/test/groovy/org/grails/forge/feature/spring/SpringBootSpec.groovy
index 4653f9eacd..0d43d92246 100644
--- 
a/grails-forge/grails-forge-core/src/test/groovy/org/grails/forge/feature/spring/SpringBootSpec.groovy
+++ 
b/grails-forge/grails-forge-core/src/test/groovy/org/grails/forge/feature/spring/SpringBootSpec.groovy
@@ -20,10 +20,12 @@
 package org.grails.forge.feature.spring
 
 import org.grails.forge.BeanContextSpec
+import org.grails.forge.BuildBuilder
 import org.grails.forge.application.ApplicationType
 import org.grails.forge.fixture.CommandOutputFixture
 import org.grails.forge.options.JdkVersion
 import org.grails.forge.options.Options
+import org.grails.forge.options.ServletImpl
 import org.grails.forge.options.TestFramework
 import spock.lang.Unroll
 
@@ -65,4 +67,16 @@ class SpringBootSpec extends BeanContextSpec implements 
CommandOutputFixture {
         build.contains("implementation 
\"org.springframework.boot:spring-boot-autoconfigure\"")
         !build.contains("implementation 
\"org.springframework.boot:spring-boot-starter-tomcat\"")
     }
+
+    void "test undertow servlet includes jboss-threads dependency"() {
+        when:
+        String build = new BuildBuilder(beanContext)
+                .servletImpl(ServletImpl.UNDERTOW)
+                .render()
+
+        then:
+        build.contains('implementation 
"org.springframework.boot:spring-boot-starter-undertow"')
+        build.contains('runtimeOnly "org.jboss.threads:jboss-threads:3.9.2"')
+        !build.contains('implementation 
"org.springframework.boot:spring-boot-starter-tomcat"')
+    }
 }

Reply via email to