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

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new c2b130b7f9 refactor: for a cleaner runtime classpath, keep logging 
related tests in a separate subproject (two additional tests)
c2b130b7f9 is described below

commit c2b130b7f9db216a8874cd48e44fd3223dca9a08
Author: Paul King <[email protected]>
AuthorDate: Sat Mar 21 07:05:51 2026 +1000

    refactor: for a cleaner runtime classpath, keep logging related tests in a 
separate subproject (two additional tests)
---
 .../src/test/groovy/bugs/Groovy6932.groovy         | 53 ++++++++++++++++++++++
 .../src/test/groovy/bugs/Groovy8060.groovy         | 44 ++++++++++++++++++
 2 files changed, 97 insertions(+)

diff --git 
a/subprojects/groovy-logging-test/src/test/groovy/bugs/Groovy6932.groovy 
b/subprojects/groovy-logging-test/src/test/groovy/bugs/Groovy6932.groovy
new file mode 100644
index 0000000000..5b6caf6e85
--- /dev/null
+++ b/subprojects/groovy-logging-test/src/test/groovy/bugs/Groovy6932.groovy
@@ -0,0 +1,53 @@
+/*
+ *  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 bugs
+
+import org.junit.jupiter.api.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+final class Groovy6932 {
+    @Test
+    void testLoggingWithinClosuresShouldHaveGuards() {
+        assertScript '''
+            @groovy.util.logging.Log
+            class C {
+                void m() {
+                    int info = 0
+                    int trace = 0
+                    log.info(createLogString(info++))
+                    log.finest(createLogString(trace++))
+                    Closure c1 = { log.info(createLogString(info++)) }
+                    c1()
+                    Closure c2 = { log.finest(createLogString(trace++)) }
+                    c2()
+                    assert info == 2
+                    assert trace == 0
+                }
+
+                String createLogString(p) {
+                    "called with $p"
+                }
+            }
+
+            new C().m()
+        '''
+    }
+}
+
diff --git 
a/subprojects/groovy-logging-test/src/test/groovy/bugs/Groovy8060.groovy 
b/subprojects/groovy-logging-test/src/test/groovy/bugs/Groovy8060.groovy
new file mode 100644
index 0000000000..d15b63fb8e
--- /dev/null
+++ b/subprojects/groovy-logging-test/src/test/groovy/bugs/Groovy8060.groovy
@@ -0,0 +1,44 @@
+/*
+ *  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 bugs
+
+import org.junit.jupiter.api.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+class Groovy8060 {
+    @Test
+    void testLoggingWithinClosuresThatAreMethodArgsShouldHaveGuards() {
+        assertScript '''
+            import groovy.util.logging.Slf4j
+
+            @Slf4j
+            class LogMain {
+                public static int count = 0
+
+                static void main(args) {
+                    assert !log.isTraceEnabled()
+                    1.times { log.trace("${count++}") }
+                    assert !count
+                }
+            }
+        '''
+    }
+}
+

Reply via email to