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

borinquenkid pushed a commit to branch fix/startup-progress-stale-opened-file
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 3b5803f22e562becca4c36efdcfe064007684ca2
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Sun Oct 11 10:00:36 2026 -0500

    fix(startup-progress): clear recorded browser launches before each feature
    
    The shared browser directory kept opened-<port>.txt files across features,
    and freePort() can hand the same port to a later feature, so 'does not open
    a browser unless asked to' could see an earlier feature's launch.
    
    Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
 .../org/apache/grails/startup/StartupProgressSpec.groovy   | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git 
a/grails-startup-progress/src/test/groovy/org/apache/grails/startup/StartupProgressSpec.groovy
 
b/grails-startup-progress/src/test/groovy/org/apache/grails/startup/StartupProgressSpec.groovy
index 35b92ae96e..a1af3901c6 100644
--- 
a/grails-startup-progress/src/test/groovy/org/apache/grails/startup/StartupProgressSpec.groovy
+++ 
b/grails-startup-progress/src/test/groovy/org/apache/grails/startup/StartupProgressSpec.groovy
@@ -125,6 +125,7 @@ class StartupProgressSpec extends Specification {
 
     void setup() {
         port = freePort()
+        browserDir.listFiles({ File file -> file.name.startsWith('opened-') } 
as FileFilter)*.delete()
         Gates.reset(port)
         standardError = System.err
         System.setErr(new PrintStream(new Tee(standardError, log), true, 
'UTF-8'))
@@ -679,6 +680,19 @@ class StartupProgressSpec extends Specification {
         !opened.exists()
     }
 
+    void 'records a browser launch that a later feature must not see'() {
+        when: 'a feature opens a browser, as the ones that ask for it do, on a 
port a later feature may be given too'
+        new File(browserDir, "opened-${port}.txt").text = 
"http://localhost:${port}/\n";
+
+        then:
+        new File(browserDir, "opened-${port}.txt").exists()
+    }
+
+    void 'starts each feature with no browser launch recorded by an earlier 
one'() {
+        expect: 'the port may repeat across features, so a stale record would 
pass for this feature opening a browser'
+        browserDir.list().findAll { String name -> name.startsWith('opened-') 
}.isEmpty()
+    }
+
     void 'serves a report of the start, as a page or as data, for as long as 
the application runs'() {
         given: 'a bean that takes its time to create'
         Gates.beanCreation = new CountDownLatch(1)

Reply via email to