You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2025/04/12 03:39:12 UTC

(groovy) branch GROOVY_4_0_X updated: GROOVY-7785: StackoverflowException when using too many chained method calls(add a test)

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

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


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
     new af76ac1d05 GROOVY-7785: StackoverflowException when using too many chained method calls(add a test)
af76ac1d05 is described below

commit af76ac1d0539c64885098913b209a8f75f7403a6
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Apr 12 12:37:02 2025 +0900

    GROOVY-7785: StackoverflowException when using too many chained method calls(add a test)
    
    (cherry picked from commit 51f43d0388de23a4ab414221e55214c207b468f8)
---
 src/test/groovy/bugs/Groovy7785.groovy | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/test/groovy/bugs/Groovy7785.groovy b/src/test/groovy/bugs/Groovy7785.groovy
new file mode 100644
index 0000000000..d0ba6697dc
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy7785.groovy
@@ -0,0 +1,33 @@
+/*
+ *  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 Groovy7785 {
+    @Test
+    void testManyChainedMethodCalls() {
+        assertScript '''
+            def r = new StringBuilder().append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append("a").append(" [...]
+            assert r.toString() == 'a' * 771
+        '''
+    }
+}