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-vfs.git


The following commit(s) were added to refs/heads/master by this push:
     new f6bf56f4 Use constant instead of magic string
f6bf56f4 is described below

commit f6bf56f404e8e3e22e0476d16153814c72077c0f
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Dec 10 13:05:39 2023 -0500

    Use constant instead of magic string
---
 .../apache/commons/vfs2/provider/hdfs/HdfsFileContentInfoFactory.java | 4 +++-
 .../java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java    | 3 ++-
 .../java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java    | 3 ++-
 commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIUtils.java | 2 +-
 .../org/apache/commons/vfs2/provider/ftp/FtpProviderTestCase.java     | 3 ++-
 .../test/java/org/apache/commons/vfs2/util/FileObjectUtilsTest.java   | 2 +-
 6 files changed, 11 insertions(+), 6 deletions(-)

diff --git 
a/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileContentInfoFactory.java
 
b/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileContentInfoFactory.java
index 9e1c8633..2117d259 100644
--- 
a/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileContentInfoFactory.java
+++ 
b/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileContentInfoFactory.java
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.vfs2.provider.hdfs;
 
+import java.nio.charset.StandardCharsets;
+
 import org.apache.commons.vfs2.FileContent;
 import org.apache.commons.vfs2.FileContentInfo;
 import org.apache.commons.vfs2.FileContentInfoFactory;
@@ -30,7 +32,7 @@ import org.apache.commons.vfs2.impl.DefaultFileContentInfo;
 public class HdfsFileContentInfoFactory implements FileContentInfoFactory {
 
     private static final String CONTENT = "text/plain";
-    private static final String ENCODING = "UTF-8";
+    private static final String ENCODING = StandardCharsets.UTF_8.name();
 
     /**
      * Creates a FileContentInfo for the given FileContent.
diff --git 
a/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java
 
b/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java
index ddcf6a12..d8170744 100644
--- 
a/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java
+++ 
b/commons-vfs2-hdfs/src/main/java/org/apache/commons/vfs2/provider/hdfs/HdfsFileSystem.java
@@ -21,6 +21,7 @@ import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 
 import org.apache.commons.io.function.Uncheck;
@@ -152,7 +153,7 @@ public class HdfsFileSystem extends AbstractFileSystem {
         if (null == fileObject) {
             String path;
             try {
-                path = URLDecoder.decode(name.getPath(), "UTF-8");
+                path = URLDecoder.decode(name.getPath(), 
StandardCharsets.UTF_8.name());
             } catch (final UnsupportedEncodingException e) {
                 path = name.getPath();
             }
diff --git 
a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java
 
b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java
index b0459df0..d6328441 100644
--- 
a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java
+++ 
b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java
@@ -18,6 +18,7 @@ package org.apache.commons.vfs2.provider.mime;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 
 import org.apache.commons.logging.Log;
@@ -40,7 +41,7 @@ import jakarta.mail.internet.MimeMessage;
 public class MimeFileSystem extends AbstractFileSystem {
     static final String NULL_BP_NAME = "_body_part_";
     static final String CONTENT_NAME = "_content";
-    static final String PREAMBLE_CHARSET = "UTF-8";
+    static final String PREAMBLE_CHARSET = StandardCharsets.UTF_8.name();
 
     private final Log log = LogFactory.getLog(MimeFileSystem.class);
 
diff --git 
a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIUtils.java 
b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIUtils.java
index 628a6846..52537b81 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIUtils.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/URIUtils.java
@@ -174,7 +174,7 @@ public class URIUtils {
     /**
      * The default charset of the protocol.  RFC 2277, 2396
      */
-    private static final String DEFAULT_PROTOCOL_CHARSET = "UTF-8";
+    private static final String DEFAULT_PROTOCOL_CHARSET = 
StandardCharsets.UTF_8.name();
 
     private static String encode(final String unescaped, final FluentBitSet 
allowed, final String charset) {
         final byte[] rawdata = URLCodecUtils.encodeUrl(allowed, 
EncodingUtils.getBytes(unescaped, charset));
diff --git 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpProviderTestCase.java
 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpProviderTestCase.java
index fafedb5e..d9c589f9 100644
--- 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpProviderTestCase.java
+++ 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/ftp/FtpProviderTestCase.java
@@ -20,6 +20,7 @@ import static 
org.apache.commons.vfs2.VfsTestUtils.getTestDirectory;
 
 import java.io.IOException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.time.Duration;
 
 import junit.framework.Test;
@@ -238,7 +239,7 @@ public class FtpProviderTestCase extends 
AbstractProviderTestConfig {
         // FtpFileType.BINARY is the default
         builder.setFileType(options, FtpFileType.BINARY);
         builder.setConnectTimeout(options, Duration.ofSeconds(10));
-        builder.setControlEncoding(options, "UTF-8");
+        builder.setControlEncoding(options, StandardCharsets.UTF_8.name());
         builder.setControlKeepAliveReplyTimeout(options, 
Duration.ofSeconds(35));
         builder.setControlKeepAliveTimeout(options, Duration.ofSeconds(30));
         builder.setMdtmLastModifiedTime(options, mdtmLastModifiedTime);
diff --git 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/FileObjectUtilsTest.java
 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/FileObjectUtilsTest.java
index 645c9d83..ce91952d 100644
--- 
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/FileObjectUtilsTest.java
+++ 
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/util/FileObjectUtilsTest.java
@@ -69,7 +69,7 @@ public class FileObjectUtilsTest {
     @Test
     public void testgetContentAsStringString() throws IOException {
         assertEquals("This is a test file.", 
FileObjectUtils.getContentAsString(
-            VFS.getManager().toFileObject(new 
File("src/test/resources/test-data/read-tests/file1.txt")), "UTF-8"));
+                VFS.getManager().toFileObject(new 
File("src/test/resources/test-data/read-tests/file1.txt")), 
StandardCharsets.UTF_8.name()));
     }
 
     @Test

Reply via email to