From ae21af110f2134ae37e59a12a3234f8bbf234aa4 Mon Sep 17 00:00:00 2001 From: leon Date: Sun, 24 Sep 2017 10:58:38 +0800 Subject: [PATCH] jdk9 --- .../java/com/moilioncircle/redis/replicator/RedisURI.java | 6 +++--- .../com/moilioncircle/redis/replicator/RedisURITest.java | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/moilioncircle/redis/replicator/RedisURI.java b/src/main/java/com/moilioncircle/redis/replicator/RedisURI.java index 44f3d081..083789df 100644 --- a/src/main/java/com/moilioncircle/redis/replicator/RedisURI.java +++ b/src/main/java/com/moilioncircle/redis/replicator/RedisURI.java @@ -42,7 +42,7 @@ public final class RedisURI implements Comparable, Serializable { private static final long serialVersionUID = 1L; - private final static char[] HEXDIGITS = { + private final static char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; @@ -286,7 +286,7 @@ private static String encode(String s) { private static void appendEscape(StringBuilder sb, byte b) { sb.append('%'); - sb.append(HEXDIGITS[(b >> 4) & 0x0F]); - sb.append(HEXDIGITS[(b >> 0) & 0x0F]); + sb.append(HEX_DIGITS[(b >> 4) & 0x0F]); + sb.append(HEX_DIGITS[(b >> 0) & 0x0F]); } } diff --git a/src/test/java/com/moilioncircle/redis/replicator/RedisURITest.java b/src/test/java/com/moilioncircle/redis/replicator/RedisURITest.java index e9ed1dcf..ee3d2f29 100644 --- a/src/test/java/com/moilioncircle/redis/replicator/RedisURITest.java +++ b/src/test/java/com/moilioncircle/redis/replicator/RedisURITest.java @@ -152,15 +152,19 @@ public void handle(Replicator replicator) { public void testURI() throws URISyntaxException, UnsupportedEncodingException { String str = "redis:///test?" + URLEncoder.encode("新建文件夹", "UTF-8") + "=dump.rdb"; RedisURI uri = new RedisURI(str); + assertEquals(str, uri.toASCIIString()); assertEquals("dump.rdb", uri.parameters.get("新建文件夹")); str = "redis:///test?" + URLEncoder.encode("新建文件夹", "UTF-8") + "=" + URLEncoder.encode("新建文件夹", "UTF-8"); uri = new RedisURI(str); + assertEquals(str, uri.toASCIIString()); assertEquals("新建文件夹", uri.parameters.get("新建文件夹")); str = "redis:///test?key=value"; uri = new RedisURI(str); + assertEquals(str, uri.toASCIIString()); assertEquals("value", uri.parameters.get("key")); str = "redis:///test?key=%20"; uri = new RedisURI(str); + assertEquals(str, uri.toASCIIString()); assertEquals(" ", uri.parameters.get("key")); } }