You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2019/07/21 10:38:23 UTC

[groovy] 02/02: GROOVY-9200: StringIndexOutOfBoundsException in AstBrowser

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

commit 75f945ec7382eb1347a824f48340d9cee09a00a7
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sun Jul 21 20:37:54 2019 +1000

    GROOVY-9200: StringIndexOutOfBoundsException in AstBrowser
---
 .../src/main/groovy/groovy/console/ui/AstBrowser.groovy             | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/AstBrowser.groovy b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/AstBrowser.groovy
index e2ac575..2009ce9 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/AstBrowser.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/AstBrowser.groovy
@@ -239,8 +239,10 @@ class AstBrowser {
                     def propList = it
                     if (propList[2] == "ListHashMap" && propList[1] != 'null' && propList[1] != '[:]') {
                         //If the class is a ListHashMap, make it accessible in a new frame through a button
+                        def kvPairs = propList[1].substring(1, propList[1].length() - 1).tokenize(',')
+                        def kvFirst = kvPairs.get(0)
                         def btnPanel = swing.button(
-                                text: "Key/value pairs: " + propList[1].tokenize(',').get(0).substring(1, 25) + "...",
+                                text: "Key/value pairs: [" + kvFirst.substring(0, Math.max(25, kvFirst.size())) + "...]",
                                 actionPerformed: {
                                     def mapTable
                                     String title = titleSuffix ? propList[0] + " (" + titleSuffix + ")" : propList[0]
@@ -261,7 +263,7 @@ class AstBrowser {
                                         }
                                     }
                                     mapTable.model.rows.clear()
-                                    propList[1].substring(1, propList[1].length() - 1).tokenize(',').each {
+                                    kvPairs.each {
                                         def kv = it.tokenize(':')
                                         if (kv)
                                             mapTable.model.rows << ["name": kv[0], "value": kv[1]]