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/25 14:34:09 UTC
[groovy] branch GROOVY_3_0_X updated: GROOVY-9658: Infinite
recursion exists in HashCodeHelper#updateHash(int, java.lang.Character)
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new e06cba7 GROOVY-9658: Infinite recursion exists in HashCodeHelper#updateHash(int, java.lang.Character)
e06cba7 is described below
commit e06cba7968c459623fb110cbf229777853a1be6c
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jul 25 22:27:40 2020 +0800
GROOVY-9658: Infinite recursion exists in HashCodeHelper#updateHash(int, java.lang.Character)
(cherry picked from commit 777c079f8ad3a031b28699afe2acf61b7825c91b)
---
.../org/codehaus/groovy/util/HashCodeHelper.java | 2 +-
.../codehaus/groovy/util/HashCodeHelperTest.groovy | 31 ++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/util/HashCodeHelper.java b/src/main/java/org/codehaus/groovy/util/HashCodeHelper.java
index 8554f27..0aacf22 100644
--- a/src/main/java/org/codehaus/groovy/util/HashCodeHelper.java
+++ b/src/main/java/org/codehaus/groovy/util/HashCodeHelper.java
@@ -42,7 +42,7 @@ public class HashCodeHelper {
}
public static int updateHash(int current, Character var) {
- return updateHash(current, var == null ? 0 : var);
+ return updateHash(current, var == null ? 0 : var.charValue());
}
public static int updateHash(int current, int var) {
diff --git a/src/test/org/codehaus/groovy/util/HashCodeHelperTest.groovy b/src/test/org/codehaus/groovy/util/HashCodeHelperTest.groovy
new file mode 100644
index 0000000..2298dd1
--- /dev/null
+++ b/src/test/org/codehaus/groovy/util/HashCodeHelperTest.groovy
@@ -0,0 +1,31 @@
+/*
+ * 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 org.codehaus.groovy.util
+
+import groovy.transform.CompileStatic
+import org.junit.Test
+
+@CompileStatic
+class HashCodeHelperTest {
+ @Test
+ void testUpdateHash() {
+ assert 158 == HashCodeHelper.updateHash(1, new Character('c' as char))
+ assert 59 == HashCodeHelper.updateHash(1, (Character) null)
+ }
+}