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 3e0e028151 Revert "Use charset constant" 3e0e028151 is described below commit 3e0e0281517653857274974799ea27d3aa7f420a Author: Daniel Sun <sun...@apache.org> AuthorDate: Sun Jul 30 04:49:50 2023 +0800 Revert "Use charset constant" [Java 8]incompatible types: java.nio.charset.Charset cannot be converted to java.lang.String This reverts commit 5b225efcb218f522c444dbfe15edd47d3b5571b8. --- src/main/java/groovy/lang/GroovyClassLoader.java | 8 ++++++-- .../groovy/contracts/util/LifecycleImplementationLoader.java | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/groovy/lang/GroovyClassLoader.java b/src/main/java/groovy/lang/GroovyClassLoader.java index b4985e2e2c..f76d77c003 100644 --- a/src/main/java/groovy/lang/GroovyClassLoader.java +++ b/src/main/java/groovy/lang/GroovyClassLoader.java @@ -66,7 +66,6 @@ import java.net.URL; import java.net.URLClassLoader; import java.net.URLConnection; import java.net.URLDecoder; -import java.nio.charset.StandardCharsets; import java.security.CodeSource; import java.security.NoSuchAlgorithmException; import java.security.Permission; @@ -998,7 +997,12 @@ public class GroovyClassLoader extends URLClassLoader { */ private static String decodeFileName(String fileName) { String decodedFile = fileName; - decodedFile = URLDecoder.decode(fileName, StandardCharsets.UTF_8); + try { + decodedFile = URLDecoder.decode(fileName, "UTF-8"); + } catch (UnsupportedEncodingException e) { + System.err.println("Encountered an invalid encoding scheme when trying to use URLDecoder.decode() inside of the GroovyClassLoader.decodeFileName() method. Returning the unencoded URL."); + System.err.println("Please note that if you encounter this error and you have spaces in your directory you will run into issues. Refer to GROOVY-1787 for description of this bug."); + } return decodedFile; } diff --git a/subprojects/groovy-contracts/src/main/java/org/apache/groovy/contracts/util/LifecycleImplementationLoader.java b/subprojects/groovy-contracts/src/main/java/org/apache/groovy/contracts/util/LifecycleImplementationLoader.java index a0112e4bc0..f79048b551 100644 --- a/subprojects/groovy-contracts/src/main/java/org/apache/groovy/contracts/util/LifecycleImplementationLoader.java +++ b/subprojects/groovy-contracts/src/main/java/org/apache/groovy/contracts/util/LifecycleImplementationLoader.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Enumeration; import java.util.Iterator; @@ -100,7 +99,7 @@ public final class LifecycleImplementationLoader<S> implements Iterable<S> { ArrayList<String> names = new ArrayList<String>(); try { in = u.openStream(); - r = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); + r = new BufferedReader(new InputStreamReader(in, "utf-8")); int lc = 1; while ((lc = parseLine(service, u, r, lc, names)) >= 0) ; } catch (IOException x) {