Repository: incubator-rocketmq Updated Branches: refs/heads/master 62d811e35 -> 457bb61f0
[ROCKETMQ-59] Change Charset usages in RocketMQSerializable to RocketMQSerializable#CHARSET_UTF8, closes apache/incubator-rocketmq#43 Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/457bb61f Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/457bb61f Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/457bb61f Branch: refs/heads/master Commit: 457bb61f0489d58c810330b40c62ccb7e75b602b Parents: 62d811e Author: iskl <[email protected]> Authored: Fri Jan 20 11:18:42 2017 +0800 Committer: yukon <[email protected]> Committed: Fri Jan 20 11:18:42 2017 +0800 ---------------------------------------------------------------------- .../remoting/protocol/RemotingSerializable.java | 2 +- .../remoting/protocol/RocketMQSerializable.java | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/457bb61f/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java ---------------------------------------------------------------------- diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java index a9c0a62..f80ff14 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java @@ -20,7 +20,7 @@ import com.alibaba.fastjson.JSON; import java.nio.charset.Charset; public abstract class RemotingSerializable { - public final static Charset CHARSET_UTF8 = Charset.forName("UTF-8"); + private final static Charset CHARSET_UTF8 = Charset.forName("UTF-8"); public static byte[] encode(final Object obj) { final String json = toJson(obj, false); http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/457bb61f/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java ---------------------------------------------------------------------- diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java index 0ebe795..86dab46 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java @@ -23,14 +23,14 @@ import java.util.Iterator; import java.util.Map; public class RocketMQSerializable { - public static final Charset CHARSET_UTF8 = Charset.forName("UTF-8"); + private static final Charset CHARSET_UTF8 = Charset.forName("UTF-8"); public static byte[] rocketMQProtocolEncode(RemotingCommand cmd) { // String remark byte[] remarkBytes = null; int remarkLen = 0; if (cmd.getRemark() != null && cmd.getRemark().length() > 0) { - remarkBytes = cmd.getRemark().getBytes(RemotingSerializable.CHARSET_UTF8); + remarkBytes = cmd.getRemark().getBytes(CHARSET_UTF8); remarkLen = remarkBytes.length; } @@ -89,9 +89,9 @@ public class RocketMQSerializable { if (entry.getKey() != null && entry.getValue() != null) { kvLength = // keySize + Key - 2 + entry.getKey().getBytes(RemotingSerializable.CHARSET_UTF8).length + 2 + entry.getKey().getBytes(CHARSET_UTF8).length // valSize + val - + 4 + entry.getValue().getBytes(RemotingSerializable.CHARSET_UTF8).length; + + 4 + entry.getValue().getBytes(CHARSET_UTF8).length; totalLength += kvLength; } } @@ -103,8 +103,8 @@ public class RocketMQSerializable { while (it.hasNext()) { Map.Entry<String, String> entry = it.next(); if (entry.getKey() != null && entry.getValue() != null) { - key = entry.getKey().getBytes(RemotingSerializable.CHARSET_UTF8); - val = entry.getValue().getBytes(RemotingSerializable.CHARSET_UTF8); + key = entry.getKey().getBytes(CHARSET_UTF8); + val = entry.getValue().getBytes(CHARSET_UTF8); content.putShort((short) key.length); content.put(key); @@ -154,7 +154,7 @@ public class RocketMQSerializable { if (remarkLength > 0) { byte[] remarkContent = new byte[remarkLength]; headerBuffer.get(remarkContent); - cmd.setRemark(new String(remarkContent, RemotingSerializable.CHARSET_UTF8)); + cmd.setRemark(new String(remarkContent, CHARSET_UTF8)); } // HashMap<String, String> extFields @@ -187,8 +187,7 @@ public class RocketMQSerializable { valContent = new byte[valSize]; byteBuffer.get(valContent); - map.put(new String(keyContent, RemotingSerializable.CHARSET_UTF8), new String(valContent, - RemotingSerializable.CHARSET_UTF8)); + map.put(new String(keyContent, CHARSET_UTF8), new String(valContent, CHARSET_UTF8)); } return map; }
