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 2020/07/23 02:18:43 UTC

[groovy] branch GROOVY-9637 updated (5fd0574 -> 623c1e6)

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

sunlan pushed a change to branch GROOVY-9637
in repository https://gitbox.apache.org/repos/asf/groovy.git.


 discard 5fd0574  Fix the compilation error in the class `Sql`
     new 623c1e6  Make `GString` final

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5fd0574)
            \
             N -- N -- N   refs/heads/GROOVY-9637 (623c1e6)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/groovy/lang/GString.java             | 10 ++---
 src/test/groovy/lang/DummyGString.java             | 47 ----------------------
 src/test/groovy/lang/DummyGStringBase.java         | 32 ---------------
 src/test/groovy/lang/GStringTest.java              | 24 +++++------
 .../codehaus/groovy/runtime/FileAppendTest.groovy  |  2 +-
 .../groovy/runtime/WriterAppendTest.groovy         |  2 +-
 .../groovy-sql/src/main/java/groovy/sql/Sql.java   | 13 +++---
 7 files changed, 26 insertions(+), 104 deletions(-)
 delete mode 100644 src/test/groovy/lang/DummyGString.java
 delete mode 100644 src/test/groovy/lang/DummyGStringBase.java


[groovy] 01/01: Make `GString` final

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 623c1e66817f13e11e31c107b1f17d8e4c6b74e2
Author: Daniel Sun <su...@apache.org>
AuthorDate: Thu Jul 23 10:18:21 2020 +0800

    Make `GString` final
---
 src/main/java/groovy/lang/GString.java             | 10 ++---
 src/test/groovy/lang/DummyGString.java             | 47 ----------------------
 src/test/groovy/lang/DummyGStringBase.java         | 32 ---------------
 src/test/groovy/lang/GStringTest.java              | 24 +++++------
 .../codehaus/groovy/runtime/FileAppendTest.groovy  |  2 +-
 .../groovy/runtime/WriterAppendTest.groovy         |  2 +-
 6 files changed, 19 insertions(+), 98 deletions(-)

diff --git a/src/main/java/groovy/lang/GString.java b/src/main/java/groovy/lang/GString.java
index ed4b937..11ef1ad 100644
--- a/src/main/java/groovy/lang/GString.java
+++ b/src/main/java/groovy/lang/GString.java
@@ -41,7 +41,7 @@ import java.util.regex.Pattern;
  * James Strachan: The lovely name of this class was suggested by Jules Gosnell
  * and was such a good idea, I couldn't resist :)
  */
-public class GString extends GroovyObjectSupport implements Comparable, CharSequence, Writable, Buildable, Serializable {
+public final class GString extends GroovyObjectSupport implements Comparable, CharSequence, Writable, Buildable, Serializable {
 
     private static final long serialVersionUID = -2638020355892246323L;
     private static final String MKP = "mkp";
@@ -99,8 +99,8 @@ public class GString extends GroovyObjectSupport implements Comparable, CharSequ
         }
     }
 
-    public final List<Object> getValues() {
-        return Arrays.asList(values);
+    public Object[] getValues() {
+        return values.clone();
     }
 
     /**
@@ -110,8 +110,8 @@ public class GString extends GroovyObjectSupport implements Comparable, CharSequ
      * the values will result in changes of the GString. It is not recommended
      * to do so.
      */
-    public final List<String> getStrings() {
-        return Arrays.asList(strings);
+    public String[] getStrings() {
+        return strings.clone();
     }
 
     public GString plus(GString that) {
diff --git a/src/test/groovy/lang/DummyGString.java b/src/test/groovy/lang/DummyGString.java
deleted file mode 100644
index beb79a1..0000000
--- a/src/test/groovy/lang/DummyGString.java
+++ /dev/null
@@ -1,47 +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 groovy.lang;
-
-/**
- * A hand crafted example GString
- */
-public class DummyGString extends DummyGStringBase {
-
-    private MetaClass metaClass;
-
-    public DummyGString(Object[] values) {
-        this(values, new String[]{"Hello ", "!"});
-    }
-
-    public DummyGString(Object[] values, String[] strings) {
-        super(values, strings);
-    }
-
-    public MetaClass getMetaClass() {
-        return metaClass;
-    }
-
-    public void setMetaClass(MetaClass metaClass) {
-        this.metaClass = metaClass;
-    }
-
-    public Object invokeMethod(String name, Object arguments) {
-        return metaClass.invokeMethod(this, name, arguments);
-    }
-}
diff --git a/src/test/groovy/lang/DummyGStringBase.java b/src/test/groovy/lang/DummyGStringBase.java
deleted file mode 100644
index d92a581..0000000
--- a/src/test/groovy/lang/DummyGStringBase.java
+++ /dev/null
@@ -1,32 +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 groovy.lang;
-
-public class DummyGStringBase extends GString {
-    protected String[] strings;
-
-    public DummyGStringBase(Object[] values) {
-        this(values, new String[]{"Hello ", "!"});
-    }
-
-    public DummyGStringBase(final Object[] values, String[] strings) {
-        super(values, strings);
-        this.strings = strings;
-    }
-}
diff --git a/src/test/groovy/lang/GStringTest.java b/src/test/groovy/lang/GStringTest.java
index 0e7655f..37025aa 100644
--- a/src/test/groovy/lang/GStringTest.java
+++ b/src/test/groovy/lang/GStringTest.java
@@ -27,14 +27,14 @@ import org.codehaus.groovy.runtime.InvokerHelper;
 public class GStringTest extends GroovyTestCase {
 
     public void testIterateOverText() {
-        DummyGString compString = new DummyGString(new Object[]{"James"});
-        assertArrayEquals(new String[]{"Hello ", "!"}, compString.getStrings().toArray(new String[0]));
-        assertArrayEquals(new Object[]{"James"}, compString.getValues().toArray());
+        GString compString = new GString(new Object[]{"James"}, new String[]{"Hello ", "!"});
+        assertArrayEquals(new String[]{"Hello ", "!"}, compString.getStrings());
+        assertArrayEquals(new Object[]{"James"}, compString.getValues());
         assertEquals("Hello James!", compString.toString());
     }
 
     public void testAppendString() {
-        DummyGString a = new DummyGString(new Object[]{"James"});
+        GString a = new GString(new Object[]{"James"}, new String[]{"Hello ", "!"});
         GString result = a.plus(" how are you?");
         assertEquals("Hello James! how are you?", result.toString());
         assertEquals('J', a.charAt(6));
@@ -42,7 +42,7 @@ public class GStringTest extends GroovyTestCase {
     }
 
     public void testAppendString2() {
-        DummyGString a = new DummyGString(new Object[]{"James"}, new String[]{"Hello "});
+        GString a = new GString(new Object[]{"James"}, new String[]{"Hello "});
         GString result = a.plus(" how are you?");
         System.out.println("Strings: " + InvokerHelper.toString(result.getStrings()));
         System.out.println("Values: " + InvokerHelper.toString(result.getValues()));
@@ -50,23 +50,23 @@ public class GStringTest extends GroovyTestCase {
     }
 
     public void testAppendGString() {
-        DummyGString a = new DummyGString(new Object[]{"James"});
-        DummyGString b = new DummyGString(new Object[]{"Bob"});
+        GString a = new GString(new Object[]{"James"}, new String[]{"Hello ", "!"});
+        GString b = new GString(new Object[]{"Bob"}, new String[]{"Hello ", "!"});
         GString result = a.plus(b);
         assertEquals("Hello James!Hello Bob!", result.toString());
     }
 
     public void testAppendGString2() {
-        DummyGString a = new DummyGString(new Object[]{"James"}, new String[]{"Hello "});
-        DummyGString b = new DummyGString(new Object[]{"Bob"}, new String[]{"Hello "});
+        GString a = new GString(new Object[]{"James"}, new String[]{"Hello "});
+        GString b = new GString(new Object[]{"Bob"}, new String[]{"Hello "});
         GString result = a.plus(b);
         assertEquals("Hello JamesHello Bob", result.toString());
     }
 
     public void testEqualsAndHashCode() {
-        DummyGString a = new DummyGString(new Object[]{Integer.valueOf(1)});
-        DummyGString b = new DummyGString(new Object[]{Long.valueOf(1)});
-        Comparable c = new DummyGString(new Object[]{new Double(2.3)});
+        GString a = new GString(new Object[]{Integer.valueOf(1)}, new String[]{"Hello ", "!"});
+        GString b = new GString(new Object[]{Long.valueOf(1)}, new String[]{"Hello ", "!"});
+        Comparable c = new GString(new Object[]{new Double(2.3)}, new String[]{"Hello ", "!"});
 
         assertTrue("a == b", a.equals(b));
         assertEquals("hashcode a == b", a.hashCode(), b.hashCode());
diff --git a/src/test/org/codehaus/groovy/runtime/FileAppendTest.groovy b/src/test/org/codehaus/groovy/runtime/FileAppendTest.groovy
index f67b240..381a452 100644
--- a/src/test/org/codehaus/groovy/runtime/FileAppendTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/FileAppendTest.groovy
@@ -43,7 +43,7 @@ class FileAppendTest extends GroovyTestCase {
               </characters>
             </groovy>
             """.stripIndent()
-    static Writable gPathResult = new DummyGStringBase(text)
+    static Writable gPathResult = new GString(text , new String[]{"Hello ", "!"})
     static gPathWriteTo;
 
     public FileAppendTest() {
diff --git a/src/test/org/codehaus/groovy/runtime/WriterAppendTest.groovy b/src/test/org/codehaus/groovy/runtime/WriterAppendTest.groovy
index 387e55f..7d59319 100644
--- a/src/test/org/codehaus/groovy/runtime/WriterAppendTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/WriterAppendTest.groovy
@@ -43,7 +43,7 @@ class WriterAppendTest extends GroovyTestCase {
               </characters>
             </groovy>
             """
-    static gPathResult = new DummyGStringBase(text)
+    static gPathResult = new GString(text, new String[]{"Hello ", "!"})
     static gPathWriteTo
     static defaultEncoding
     static UTF8_ENCODING