This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-net.git
The following commit(s) were added to refs/heads/master by this push: new 2868f8b4 Use constant instead of magic string 2868f8b4 is described below commit 2868f8b468da54265f33e4ba99eb3bb47f29cb36 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Dec 10 11:06:43 2023 -0500 Use constant instead of magic string --- src/main/java/org/apache/commons/net/ftp/FTPClient.java | 5 +++-- src/test/java/org/apache/commons/net/examples/MainTest.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/net/ftp/FTPClient.java b/src/main/java/org/apache/commons/net/ftp/FTPClient.java index c269296c..a0bffd7e 100644 --- a/src/main/java/org/apache/commons/net/ftp/FTPClient.java +++ b/src/main/java/org/apache/commons/net/ftp/FTPClient.java @@ -34,6 +34,7 @@ import java.net.Socket; import java.net.SocketException; import java.net.SocketTimeoutException; import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; @@ -609,9 +610,9 @@ public class FTPClient extends FTP implements Configurable { if (autodetectEncoding) { final ArrayList<String> oldReplyLines = new ArrayList<>(_replyLines); final int oldReplyCode = _replyCode; - if (hasFeature("UTF8") || hasFeature("UTF-8")) // UTF8 appears to be the default + if (hasFeature("UTF8") || hasFeature(StandardCharsets.UTF_8.name())) // UTF-8 appears to be the default { - setControlEncoding("UTF-8"); + setControlEncoding(StandardCharsets.UTF_8.name()); _controlInput_ = new CRLFLineReader(new InputStreamReader(_input_, getControlEncoding())); _controlOutput_ = new BufferedWriter(new OutputStreamWriter(_output_, getControlEncoding())); } diff --git a/src/test/java/org/apache/commons/net/examples/MainTest.java b/src/test/java/org/apache/commons/net/examples/MainTest.java index 9858b482..d2caabb9 100644 --- a/src/test/java/org/apache/commons/net/examples/MainTest.java +++ b/src/test/java/org/apache/commons/net/examples/MainTest.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.security.CodeSource; import java.util.Enumeration; import java.util.Properties; @@ -84,7 +85,7 @@ public class MainTest { final CodeSource codeSource = Main.class.getProtectionDomain().getCodeSource(); // ensure special characters are decoded OK by uing the charset // Use canonical path to ensure consistency with Windows - final String sourceFile = new File(URLDecoder.decode(codeSource.getLocation().getFile(), "UTF-8")).getCanonicalPath(); + final String sourceFile = new File(URLDecoder.decode(codeSource.getLocation().getFile(), StandardCharsets.UTF_8.name())).getCanonicalPath(); final Properties p = new Properties(); if (sourceFile.endsWith(".jar")) { try (final JarFile jf = new JarFile(sourceFile)) {