Skip to content

Commit

Permalink
Replace jackson-mapper-asl with fastjson (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
quaff authored and gosonzhang committed Sep 19, 2019
1 parent 89e19b0 commit 0d1f036
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 25 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Expand Up @@ -149,11 +149,6 @@
<artifactId>fastjson</artifactId>
<version>1.2.60</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Expand Down
4 changes: 0 additions & 4 deletions tubemq-server/pom.xml
Expand Up @@ -101,10 +101,6 @@
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
Expand Down
Expand Up @@ -17,6 +17,8 @@

package com.tencent.tubemq.server.common.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.tencent.tubemq.corebase.TBaseConstants;
import com.tencent.tubemq.corebase.TokenConstants;
import com.tencent.tubemq.corebase.utils.TStringUtils;
Expand All @@ -26,7 +28,6 @@
import com.tencent.tubemq.server.master.bdbstore.bdbentitys.BdbBrokerConfEntity;
import com.tencent.tubemq.server.master.nodemanage.nodebroker.BrokerConfManage;
import com.tencent.tubemq.server.master.nodemanage.nodebroker.BrokerSyncStatusInfo;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
Expand Down Expand Up @@ -608,7 +609,7 @@ public static Set<BdbBrokerConfEntity> getBatchBrokerIdSet(String inStrBrokerIds
* @return a list of linked hash map represent the json array
* @throws Exception
*/
public static List<LinkedHashMap<String, Object>> checkAndGetJsonArray(String paramName,
public static List<Map<String, Object>> checkAndGetJsonArray(String paramName,
Object paramValue,
int paramMaxLen,
boolean required) throws Exception {
Expand Down Expand Up @@ -642,8 +643,7 @@ public static List<LinkedHashMap<String, Object>> checkAndGetJsonArray(String pa
.append(" characters").toString());
}
}
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readValue(decTmpParamVal, List.class);
return JSON.parseObject(decTmpParamVal, new TypeReference<List<Map<String, Object>>>() {});
}

/**
Expand Down
Expand Up @@ -152,7 +152,7 @@ public StringBuilder adminBathAddGroupFilterCondInfo(HttpServletRequest req) thr
req.getParameter("createDate"),
TBaseConstants.META_MAX_DATEVALUE_LENGTH,
false, new Date());
List<LinkedHashMap<String, Object>> filterJsonArray =
List<Map<String, Object>> filterJsonArray =
WebParameterUtils.checkAndGetJsonArray("filterCondJsonSet",
req.getParameter("filterCondJsonSet"),
TBaseConstants.META_VALUE_UNDEFINED, true);
Expand Down Expand Up @@ -350,7 +350,7 @@ public StringBuilder adminBathModGroupFilterCondInfo(HttpServletRequest req) thr
req.getParameter("modifyDate"),
TBaseConstants.META_MAX_DATEVALUE_LENGTH,
false, new Date());
List<LinkedHashMap<String, Object>> jsonArray =
List<Map<String, Object>> jsonArray =
WebParameterUtils.checkAndGetJsonArray("filterCondJsonSet",
req.getParameter("filterCondJsonSet"),
TBaseConstants.META_VALUE_UNDEFINED, true);
Expand Down Expand Up @@ -758,7 +758,7 @@ public StringBuilder adminBathAddConsumerGroupInfo(HttpServletRequest req) throw
req.getParameter("createDate"),
TBaseConstants.META_MAX_DATEVALUE_LENGTH,
false, new Date());
List<LinkedHashMap<String, Object>> jsonArray =
List<Map<String, Object>> jsonArray =
WebParameterUtils.checkAndGetJsonArray("groupNameJsonSet",
req.getParameter("groupNameJsonSet"),
TBaseConstants.META_VALUE_UNDEFINED, true);
Expand Down Expand Up @@ -1026,7 +1026,7 @@ public StringBuilder adminBathAddBlackGroupInfo(HttpServletRequest req) throws E
req.getParameter("createDate"),
TBaseConstants.META_MAX_DATEVALUE_LENGTH,
false, new Date());
List<LinkedHashMap<String, Object>> jsonArray =
List<Map<String, Object>> jsonArray =
WebParameterUtils.checkAndGetJsonArray("groupNameJsonSet",
req.getParameter("groupNameJsonSet"),
TBaseConstants.META_VALUE_UNDEFINED, true);
Expand Down Expand Up @@ -1273,7 +1273,7 @@ public StringBuilder adminBathAddConsumeGroupSetting(HttpServletRequest req) thr
WebParameterUtils.validIntDataParameter("allowedBClientRate",
req.getParameter("allowedBClientRate"),
false, 0, 0);
List<LinkedHashMap<String, Object>> groupNameJsonArray =
List<Map<String, Object>> groupNameJsonArray =
WebParameterUtils.checkAndGetJsonArray("groupNameJsonSet",
req.getParameter("groupNameJsonSet"),
TBaseConstants.META_VALUE_UNDEFINED, true);
Expand Down
Expand Up @@ -17,6 +17,8 @@

package com.tencent.tubemq.server.master.web.handler;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.tencent.tubemq.corebase.TBaseConstants;
import com.tencent.tubemq.corebase.utils.TStringUtils;
import com.tencent.tubemq.server.common.utils.WebParameterUtils;
Expand All @@ -25,7 +27,6 @@
import com.tencent.tubemq.server.master.bdbstore.bdbentitys.BdbGroupFilterCondEntity;
import com.tencent.tubemq.server.master.bdbstore.bdbentitys.BdbTopicAuthControlEntity;
import com.tencent.tubemq.server.master.nodemanage.nodebroker.BrokerConfManage;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -110,7 +111,7 @@ public StringBuilder adminBathAddTopicAuthControl(HttpServletRequest req) throws
Date createDate =
WebParameterUtils.validDateParameter("createDate", req.getParameter("createDate"),
TBaseConstants.META_MAX_DATEVALUE_LENGTH, false, new Date());
List<LinkedHashMap<String, Object>> topicJsonArray =
List<Map<String, Object>> topicJsonArray =
WebParameterUtils.checkAndGetJsonArray("topicJsonSet",
req.getParameter("topicJsonSet"), TBaseConstants.META_VALUE_UNDEFINED, true);
if ((topicJsonArray == null) || (topicJsonArray.isEmpty())) {
Expand Down Expand Up @@ -351,9 +352,8 @@ private HashMap<String, BdbConsumerGroupEntity> getAuthConsumeGroupInfo(
final StringBuilder sBuilder) throws Exception {
String strAuthConsumGroup = (String) jsonObject.get("authConsumeGroup");
if ((strAuthConsumGroup != null) && (!TStringUtils.isBlank(strAuthConsumGroup))) {
ObjectMapper objectMapper2 = new ObjectMapper();
List<LinkedHashMap<String, String>> authConsumeGroupSet =
objectMapper2.readValue(strAuthConsumGroup, List.class);
List<Map<String, String>> authConsumeGroupSet =
JSON.parseObject(strAuthConsumGroup, new TypeReference<List<Map<String, String>>>() {});
if ((authConsumeGroupSet != null)
&& (!authConsumeGroupSet.isEmpty())) {
for (int count_j = 0; count_j < authConsumeGroupSet.size(); count_j++) {
Expand Down
Expand Up @@ -321,7 +321,7 @@ public StringBuilder adminBathAddBrokerDefConfEntityInfo(HttpServletRequest req)
Date createDate =
WebParameterUtils.validDateParameter("createDate", req.getParameter("createDate"),
TBaseConstants.META_MAX_DATEVALUE_LENGTH, false, new Date());
List<LinkedHashMap<String, Object>> brokerJsonArray =
List<Map<String, Object>> brokerJsonArray =
WebParameterUtils.checkAndGetJsonArray("brokerJsonSet",
req.getParameter("brokerJsonSet"), TBaseConstants.META_VALUE_UNDEFINED, true);
if ((brokerJsonArray == null) || (brokerJsonArray.isEmpty())) {
Expand Down
Expand Up @@ -227,7 +227,7 @@ public StringBuilder adminBathAddTopicEntityInfo(HttpServletRequest req) throws
Date createDate =
WebParameterUtils.validDateParameter("createDate", req.getParameter("createDate"),
TBaseConstants.META_MAX_DATEVALUE_LENGTH, false, new Date());
List<LinkedHashMap<String, Object>> topicJsonArray =
List<Map<String, Object>> topicJsonArray =
WebParameterUtils.checkAndGetJsonArray("topicJsonSet",
req.getParameter("topicJsonSet"), TBaseConstants.META_VALUE_UNDEFINED, true);
if ((topicJsonArray == null) || (topicJsonArray.isEmpty())) {
Expand Down

0 comments on commit 0d1f036

Please sign in to comment.