This is an automated email from the ASF dual-hosted git repository. tv pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
The following commit(s) were added to refs/heads/master by this push: new 4cfb9ae Use StandardCharsets 4cfb9ae is described below commit 4cfb9ae9accc72883ab2e0e7a845f295ed310b09 Author: Thomas Vandahl <t...@apache.org> AuthorDate: Mon Nov 18 15:37:24 2019 +0100 Use StandardCharsets --- .../auxiliary/lateral/socket/tcp/LateralTCPService.java | 3 ++- .../remote/http/client/RemoteHttpCacheDispatcher.java | 3 ++- .../remote/server/RemoteCacheStartupServlet.java | 3 ++- .../disk/block/BlockDiskCacheUnitTestAbstract.java | 16 +++++++--------- .../disk/indexed/IndexDiskCacheUnitTestAbstract.java | 6 +++--- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java index ac90834..068ad3c 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java @@ -22,6 +22,7 @@ package org.apache.commons.jcs.auxiliary.lateral.socket.tcp; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -414,7 +415,7 @@ public class LateralTCPService<K, V> boolean notDone = true; String message = null; // wait to dispose - BufferedReader br = new BufferedReader( new InputStreamReader( System.in, "UTF-8" ) ); + BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); while ( notDone ) { diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java index 3bf3c99..7b80ef9 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java @@ -21,6 +21,7 @@ package org.apache.commons.jcs.auxiliary.remote.http.client; import java.io.IOException; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheDispatcher; import org.apache.commons.jcs.auxiliary.remote.value.RemoteCacheRequest; @@ -41,7 +42,7 @@ public class RemoteHttpCacheDispatcher implements IRemoteCacheDispatcher { /** Parameter encoding */ - private static final Charset DEFAULT_ENCODING = Charset.forName("UTF-8"); + private static final Charset DEFAULT_ENCODING = StandardCharsets.UTF_8; /** Named of the parameter */ private static final String PARAMETER_REQUEST_TYPE = "RequestType"; diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java index 59241f6..538f64f 100644 --- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java +++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java @@ -22,6 +22,7 @@ package org.apache.commons.jcs.auxiliary.remote.server; import java.io.IOException; import java.io.OutputStream; import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; import java.util.Properties; import javax.servlet.ServletConfig; @@ -180,7 +181,7 @@ public class RemoteCacheStartupServlet String characterEncoding = response.getCharacterEncoding(); if (characterEncoding == null) { - characterEncoding = "UTF-8"; + characterEncoding = StandardCharsets.UTF_8.name(); response.setCharacterEncoding(characterEncoding); } OutputStream os = response.getOutputStream(); diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java index 45f816c..fb6e7db 100644 --- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java +++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java @@ -22,6 +22,7 @@ package org.apache.commons.jcs.auxiliary.disk.block; import java.io.File; import java.io.IOException; import java.io.Serializable; +import java.nio.charset.StandardCharsets; import java.util.Map; import junit.framework.TestCase; @@ -249,8 +250,7 @@ public abstract class BlockDiskCacheUnitTestAbstract extends TestCase } string = sb.toString(); // System.out.println( "The string contains " + string.length() + " characters" ); - String UTF8 = "UTF-8"; - byte[] bytes = string.getBytes(UTF8); + byte[] bytes = string.getBytes(StandardCharsets.UTF_8); String cacheName = "testUTF8ByteArray"; @@ -275,7 +275,7 @@ public abstract class BlockDiskCacheUnitTestAbstract extends TestCase assertNotNull(after); assertEquals("wrong bytes after retrieval", bytes.length, after.length); // assertEquals( "wrong bytes after retrieval", bytes, after ); - // assertEquals( "wrong bytes after retrieval", string, new String( after, UTF8 ) ); + // assertEquals( "wrong bytes after retrieval", string, new String( after, StandardCharsets.UTF_8 ) ); } @@ -297,9 +297,8 @@ public abstract class BlockDiskCacheUnitTestAbstract extends TestCase } string = sb.toString(); // System.out.println( "The string contains " + string.length() + " characters" ); - String UTF8 = "UTF-8"; before.string = string; - before.bytes = string.getBytes(UTF8); + before.bytes = string.getBytes(StandardCharsets.UTF_8); String cacheName = "testUTF8StringAndBytes"; @@ -322,7 +321,7 @@ public abstract class BlockDiskCacheUnitTestAbstract extends TestCase assertNotNull(after); assertEquals("wrong string after retrieval", string, after.string); - assertEquals("wrong bytes after retrieval", string, new String(after.bytes, UTF8)); + assertEquals("wrong bytes after retrieval", string, new String(after.bytes, StandardCharsets.UTF_8)); } @@ -372,9 +371,8 @@ public abstract class BlockDiskCacheUnitTestAbstract extends TestCase sb.append(sb.toString()); // big string } string = sb.toString(); - String UTF8 = "UTF-8"; before.string = string; - before.bytes = string.getBytes(UTF8); + before.bytes = string.getBytes(StandardCharsets.UTF_8); // initialize cache String cacheName = "testLoadFromDisk"; @@ -403,7 +401,7 @@ public abstract class BlockDiskCacheUnitTestAbstract extends TestCase assertNotNull(after); assertEquals("wrong string after retrieval", string, after.string); - assertEquals("wrong bytes after retrieval", string, new String(after.bytes, UTF8)); + assertEquals("wrong bytes after retrieval", string, new String(after.bytes, StandardCharsets.UTF_8)); } diskCache.dispose(); diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java index da4f5b3..3bc4eb8 100644 --- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java +++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java @@ -20,6 +20,7 @@ package org.apache.commons.jcs.auxiliary.disk.indexed; */ import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -770,8 +771,7 @@ public abstract class IndexDiskCacheUnitTestAbstract extends TestCase } string = sb.toString(); // System.out.println( "The string contains " + string.length() + " characters" ); - String UTF8 = "UTF-8"; - byte[] bytes = string.getBytes(UTF8); + byte[] bytes = string.getBytes(StandardCharsets.UTF_8); String cacheName = "testUTF8ByteArray"; @@ -793,7 +793,7 @@ public abstract class IndexDiskCacheUnitTestAbstract extends TestCase byte[] after = afterElement.getVal(); assertNotNull(after); - assertEquals("wrong bytes after retrieval", string, new String(after, UTF8)); + assertEquals("wrong bytes after retrieval", string, new String(after, StandardCharsets.UTF_8)); } /**