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

jonnybot pushed a commit to branch bugfix/288-remove-unhelpful-dual-cache
in repository https://gitbox.apache.org/repos/asf/groovy-geb.git

commit 008b53c19a584491a4995430fe41ccb547a055d1
Author: Jonny Carter <[email protected]>
AuthorDate: Mon Dec 29 15:52:22 2025 -0600

    Revert "Fix the driver caching so that global and per-thread cache do not 
step on each others toes"
    
    This reverts commit 1ee94335291e5e63520a9eeb6aeebf87a1cf2844.
---
 .../groovy/geb/driver/CachingDriverFactory.groovy  | 15 +++-----
 .../geb/driver/CachingDriverFactorySpec.groovy     | 45 ----------------------
 2 files changed, 6 insertions(+), 54 deletions(-)

diff --git 
a/module/geb-core/src/main/groovy/geb/driver/CachingDriverFactory.groovy 
b/module/geb-core/src/main/groovy/geb/driver/CachingDriverFactory.groovy
index f4550123..6911fc1b 100644
--- a/module/geb-core/src/main/groovy/geb/driver/CachingDriverFactory.groovy
+++ b/module/geb-core/src/main/groovy/geb/driver/CachingDriverFactory.groovy
@@ -22,8 +22,7 @@ import org.openqa.selenium.WebDriver
 
 class CachingDriverFactory implements DriverFactory {
 
-    static private final GLOBAL_CACHE = new SimpleCache<Cache<WebDriver>>()
-    static private final PER_THREAD_CACHE = new SimpleCache<Cache<WebDriver>>()
+    static private final CACHE = new SimpleCache<Cache<WebDriver>>()
 
     private final Cache<WebDriver> cache
     private final DriverFactory innerFactory
@@ -36,16 +35,15 @@ class CachingDriverFactory implements DriverFactory {
     }
 
     static CachingDriverFactory global(DriverFactory innerFactory, boolean 
quitOnShutdown) {
-        new CachingDriverFactory(GLOBAL_CACHE.get { new 
SimpleCache<WebDriver>() }, innerFactory, quitOnShutdown)
+        new CachingDriverFactory(CACHE.get { new SimpleCache<WebDriver>() }, 
innerFactory, quitOnShutdown)
     }
 
     static CachingDriverFactory perThread(DriverFactory innerFactory, boolean 
quitOnShutdown) {
-        new CachingDriverFactory(PER_THREAD_CACHE.get { new 
ThreadLocalCache<WebDriver>() }, innerFactory, quitOnShutdown)
+        new CachingDriverFactory(CACHE.get { new ThreadLocalCache<WebDriver>() 
}, innerFactory, quitOnShutdown)
     }
 
     static WebDriver clearCache() {
-        GLOBAL_CACHE.get { null }?.clear()
-        PER_THREAD_CACHE.get { null }?.clear()
+        CACHE.get { null }?.clear()
     }
 
     static WebDriver clearCacheAndQuitDriver() {
@@ -55,8 +53,7 @@ class CachingDriverFactory implements DriverFactory {
     }
 
     static clearCacheCache() {
-        GLOBAL_CACHE.clear()
-        PER_THREAD_CACHE.clear()
+        CACHE.clear()
     }
 
     WebDriver getDriver() {
@@ -115,4 +112,4 @@ class CachingDriverFactory implements DriverFactory {
             prev
         }
     }
-}
+}
\ No newline at end of file
diff --git 
a/module/geb-core/src/test/groovy/geb/driver/CachingDriverFactorySpec.groovy 
b/module/geb-core/src/test/groovy/geb/driver/CachingDriverFactorySpec.groovy
deleted file mode 100644
index 36c7a3b0..00000000
--- a/module/geb-core/src/test/groovy/geb/driver/CachingDriverFactorySpec.groovy
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *  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
- *
- *    http://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 geb.driver
-
-import org.openqa.selenium.WebDriver
-import spock.lang.Specification
-import spock.util.concurrent.BlockingVariable
-
-class CachingDriverFactorySpec extends Specification {
-    def "global driver and per-thread driver factories are independent"() {
-        given:
-        def stubFactory = Stub(DriverFactory)
-        def globalFactory = CachingDriverFactory.global(stubFactory, false)
-        def perThreadFactory = CachingDriverFactory.perThread(stubFactory, 
false)
-        def globalDriver2 = new BlockingVariable<WebDriver>()
-        def perThreadDriver2 = new BlockingVariable<WebDriver>()
-
-        when:
-        def globalDriver1 = globalFactory.driver
-        Thread.start { globalDriver2.set(globalFactory.driver) }
-        def perThreadDriver1 = perThreadFactory.driver
-        Thread.start { perThreadDriver2.set(perThreadFactory.driver) }
-
-        then:
-        globalDriver1 == globalDriver2.get()
-        globalDriver1 != perThreadDriver1
-        perThreadDriver1 != perThreadDriver2.get()
-    }
-}

Reply via email to