From 00d8967b94211ed8e479c44c91027ddfffd84b42 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Sun, 22 Oct 2017 18:32:09 +0800 Subject: [PATCH 01/13] Change json to fastjson --- dubbo-common/pom.xml | 1 - .../rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dubbo-common/pom.xml b/dubbo-common/pom.xml index 4ec939b68da..bc4c8db480e 100644 --- a/dubbo-common/pom.xml +++ b/dubbo-common/pom.xml @@ -54,7 +54,6 @@ com.alibaba fastjson - provided org.jvnet.sorcerer diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java index 50a6c763470..33a29c33d6b 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java @@ -16,7 +16,6 @@ package com.alibaba.dubbo.rpc.protocol.dubbo.telnet; import com.alibaba.dubbo.common.extension.Activate; -import com.alibaba.dubbo.common.json.JSON; import com.alibaba.dubbo.common.utils.PojoUtils; import com.alibaba.dubbo.common.utils.ReflectUtils; import com.alibaba.dubbo.common.utils.StringUtils; @@ -28,6 +27,7 @@ import com.alibaba.dubbo.rpc.RpcContext; import com.alibaba.dubbo.rpc.RpcInvocation; import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol; +import com.alibaba.fastjson.JSON; import java.lang.reflect.Method; import java.util.Collection; @@ -110,7 +110,7 @@ public String telnet(Channel channel, String message) { } List list; try { - list = (List) JSON.parse("[" + args + "]", List.class); + list = JSON.parseArray("[" + args + "]", Object.class); } catch (Throwable t) { return "Invalid json argument, cause: " + t.getMessage(); } @@ -141,7 +141,7 @@ public String telnet(Channel channel, String message) { long start = System.currentTimeMillis(); Object result = invoker.invoke(new RpcInvocation(invokeMethod, array)).recreate(); long end = System.currentTimeMillis(); - buf.append(JSON.json(result)); + buf.append(JSON.toJSON(result)); buf.append("\r\nelapsed: "); buf.append(end - start); buf.append(" ms."); From 9740f4cef784a33915fba081be1c5b02fe55c396 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Mon, 23 Oct 2017 14:43:57 +0800 Subject: [PATCH 02/13] Fix typo: delete extra semicolon --- .../com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java | 1 - 1 file changed, 1 deletion(-) diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java index 12e4a214539..b26a41fd6bc 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java @@ -35,7 +35,6 @@ public abstract class AbstractProxyProtocol extends AbstractProtocol { private final List> rpcExceptions = new CopyOnWriteArrayList>(); - ; private ProxyFactory proxyFactory; From 2ee2d2d8f8eea081d9ed59805edb900e3fcc8a68 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Mon, 23 Oct 2017 16:22:52 +0800 Subject: [PATCH 03/13] Fix dubbo process detect error in shell script(start.sh dump.sh ...) --- .../src/main/resources/META-INF/assembly/bin/dump.sh | 2 +- .../src/main/resources/META-INF/assembly/bin/start.sh | 6 +++--- .../src/main/resources/META-INF/assembly/bin/stop.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/dump.sh b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/dump.sh index c0e341ae74c..d63098bb1a5 100755 --- a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/dump.sh +++ b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/dump.sh @@ -12,7 +12,7 @@ if [ -z "$SERVER_NAME" ]; then SERVER_NAME=`hostname` fi -PIDS=`ps -ef | grep java | grep "$CONF_DIR" |awk '{print $2}'` +PIDS=`ps -ef | grep java | grep -v grep | grep "$CONF_DIR" |awk '{print $2}'` if [ -z "$PIDS" ]; then echo "ERROR: The $SERVER_NAME does not started!" exit 1 diff --git a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh index 8bbea8d0a5f..410a1552802 100755 --- a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh +++ b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh @@ -14,7 +14,7 @@ if [ -z "$SERVER_NAME" ]; then SERVER_NAME=`hostname` fi -PIDS=`ps -ef | grep java | grep "$CONF_DIR" |awk '{print $2}'` +PIDS=`ps -ef | grep java | grep -v grep | grep "$CONF_DIR" |awk '{print $2}'` if [ -n "$PIDS" ]; then echo "ERROR: The $SERVER_NAME already started!" echo "PID: $PIDS" @@ -74,7 +74,7 @@ while [ $COUNT -lt 1 ]; do COUNT=`netstat -an | grep $SERVER_PORT | wc -l` fi else - COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l` + COUNT=`ps -f | grep java | grep -v grep | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l` fi if [ $COUNT -gt 0 ]; then break @@ -82,6 +82,6 @@ while [ $COUNT -lt 1 ]; do done echo "OK!" -PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'` +PIDS=`ps -f | grep java | grep -v grep | grep "$DEPLOY_DIR" | awk '{print $2}'` echo "PID: $PIDS" echo "STDOUT: $STDOUT_FILE" diff --git a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/stop.sh b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/stop.sh index 91bbd184606..8fca15e3d64 100755 --- a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/stop.sh +++ b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/stop.sh @@ -11,7 +11,7 @@ if [ -z "$SERVER_NAME" ]; then SERVER_NAME=`hostname` fi -PIDS=`ps -ef | grep java | grep "$CONF_DIR" |awk '{print $2}'` +PIDS=`ps -ef | grep java | grep -v grep | grep "$CONF_DIR" |awk '{print $2}'` if [ -z "$PIDS" ]; then echo "ERROR: The $SERVER_NAME does not started!" exit 1 From 0d6e17070c830c377121e9ed70c9434e23808500 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Tue, 24 Oct 2017 17:13:10 +0800 Subject: [PATCH 04/13] Change JSON to fastjson & mark JSON deprecated --- .../alibaba/dubbo/common/json/GenericJSONConverter.java | 1 + .../java/com/alibaba/dubbo/common/json/J2oVisitor.java | 2 +- .../src/main/java/com/alibaba/dubbo/common/json/JSON.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONArray.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONConverter.java | 2 +- .../main/java/com/alibaba/dubbo/common/json/JSONNode.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONObject.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONReader.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONToken.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONVisitor.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONWriter.java | 2 +- .../com/alibaba/dubbo/common/json/ParseException.java | 2 +- .../main/java/com/alibaba/dubbo/common/json/Yylex.java | 1 + .../common/serialize/support/json/JsonObjectInput.java | 1 + .../common/serialize/support/json/JsonObjectOutput.java | 1 + .../common/serialize/support/json/JsonSerialization.java | 1 + .../java/com/alibaba/dubbo/common/utils/StringUtils.java | 7 +++---- .../com.alibaba.dubbo.common.serialize.Serialization | 1 - .../test/java/com/alibaba/dubbo/common/json/JSONTest.java | 1 + dubbo-demo/dubbo-demo-consumer/pom.xml | 4 ++++ dubbo-demo/dubbo-demo-provider/pom.xml | 4 ++++ .../com/alibaba/dubbo/rpc/filter/AccessLogFilter.java | 4 ++-- .../java/com/alibaba/dubbo/rpc/support/MockInvoker.java | 8 ++++---- .../dubbo/rpc/protocol/dubbo/filter/TraceFilter.java | 4 ++-- 24 files changed, 36 insertions(+), 24 deletions(-) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java index f0cb594b05d..35542ceb277 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java @@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +@Deprecated public class GenericJSONConverter implements JSONConverter { private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; private static final Map, Encoder> GlobalEncoderMap = new HashMap, Encoder>(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java index 2f27395271f..d2b352a9e4b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java @@ -36,7 +36,7 @@ * * @author qian.lei. */ - +@Deprecated class J2oVisitor implements JSONVisitor { public static final boolean[] EMPTY_BOOL_ARRAY = new boolean[0]; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSON.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSON.java index e54f4bad5fc..0cba4a250a3 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSON.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSON.java @@ -29,7 +29,7 @@ * * @author qian.lei */ - +@Deprecated public class JSON { public static final char LBRACE = '{', RBRACE = '}'; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java index 1fc645d23ca..8b96ff1d2c5 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java @@ -25,7 +25,7 @@ * * @author qian.lei */ - +@Deprecated public class JSONArray implements JSONNode { private List mArray = new ArrayList(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONConverter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONConverter.java index e550c3235e8..c29fcf8e096 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONConverter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONConverter.java @@ -22,7 +22,7 @@ * * @author qianlei */ - +@Deprecated public interface JSONConverter { /** * write object. diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONNode.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONNode.java index 4d546e45fee..aa8531e119f 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONNode.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONNode.java @@ -22,7 +22,7 @@ * * @author qian.lei */ - +@Deprecated interface JSONNode { /** * write json string. diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java index 6b2defde016..680b965171e 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java @@ -25,7 +25,7 @@ * * @author qian.lei */ - +@Deprecated public class JSONObject implements JSONNode { private Map mMap = new HashMap(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONReader.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONReader.java index 4e1728e2993..ae760ebf229 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONReader.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONReader.java @@ -26,7 +26,7 @@ * * @author qian.lei */ - +@Deprecated public class JSONReader { private static ThreadLocal LOCAL_LEXER = new ThreadLocal() { }; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONToken.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONToken.java index 4154b37dcae..bfdab9cf76b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONToken.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONToken.java @@ -20,7 +20,7 @@ * * @author qian.lei */ - +@Deprecated public class JSONToken { // token type public static final int ANY = 0, IDENT = 0x01, LBRACE = 0x02, LSQUARE = 0x03, RBRACE = 0x04, RSQUARE = 0x05, COMMA = 0x06, COLON = 0x07; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONVisitor.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONVisitor.java index 337ecceb642..7c27bd1d1c8 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONVisitor.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONVisitor.java @@ -20,7 +20,7 @@ * * @author qian.lei */ - +@Deprecated public interface JSONVisitor { public static final String CLASS_PROPERTY = "class"; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONWriter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONWriter.java index ced85f9707a..c62fb09a5b9 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONWriter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONWriter.java @@ -30,7 +30,7 @@ * * @author qian.lei */ - +@Deprecated public class JSONWriter { private static final byte UNKNOWN = 0, ARRAY = 1, OBJECT = 2, OBJECT_VALUE = 3; private static final String[] CONTROL_CHAR_MAP = new String[]{ diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/ParseException.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/ParseException.java index 64e009cfeb9..6785721550b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/ParseException.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/ParseException.java @@ -20,7 +20,7 @@ * * @author qian.lei */ - +@Deprecated public class ParseException extends Exception { private static final long serialVersionUID = 8611884051738966316L; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/Yylex.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/Yylex.java index 36992aee561..7471a2a83d7 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/Yylex.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/Yylex.java @@ -21,6 +21,7 @@ * on 7/3/10 3:12 AM from the specification file * /Users/qianlei/dev/proj/dubbo-1.1/dubbo.common/src/main/java/com/alibaba/dubbo/common/json/json.flex */ +@Deprecated public class Yylex { /** diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java index b2b5c89157a..a250e0dba2b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java @@ -35,6 +35,7 @@ * @author william.liangf * @author ding.lid */ +@Deprecated public class JsonObjectInput implements ObjectInput { private final BufferedReader reader; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java index eeb35b63eec..fb9710ed588 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java @@ -29,6 +29,7 @@ * * @author william.liangf */ +@Deprecated public class JsonObjectOutput implements ObjectOutput { private final PrintWriter writer; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java index 7243d9e27a3..585bf50040d 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java @@ -29,6 +29,7 @@ * * @author william.liangf */ +@Deprecated public class JsonSerialization implements Serialization { public byte getContentTypeId() { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java index f4f4436dde8..2926db712f0 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java @@ -17,11 +17,10 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.io.UnsafeStringWriter; -import com.alibaba.dubbo.common.json.JSON; +import com.alibaba.fastjson.JSON; import com.alibaba.dubbo.common.logger.Logger; import com.alibaba.dubbo.common.logger.LoggerFactory; -import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; @@ -420,8 +419,8 @@ public static String toArgumentString(Object[] args) { buf.append(arg); } else { try { - buf.append(JSON.json(arg)); - } catch (IOException e) { + buf.append(JSON.toJSONString(arg)); + } catch (Exception e) { logger.warn(e.getMessage(), e); buf.append(arg); } diff --git a/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization b/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization index ca493e45799..01fb3035124 100644 --- a/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization +++ b/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization @@ -2,6 +2,5 @@ dubbo=com.alibaba.dubbo.common.serialize.support.dubbo.DubboSerialization hessian2=com.alibaba.dubbo.common.serialize.support.hessian.Hessian2Serialization java=com.alibaba.dubbo.common.serialize.support.java.JavaSerialization compactedjava=com.alibaba.dubbo.common.serialize.support.java.CompactedJavaSerialization -json=com.alibaba.dubbo.common.serialize.support.json.JsonSerialization fastjson=com.alibaba.dubbo.common.serialize.support.json.FastJsonSerialization nativejava=com.alibaba.dubbo.common.serialize.support.nativejava.NativeJavaSerialization \ No newline at end of file diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/json/JSONTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/json/JSONTest.java index 1099c9d151d..eb846ea3f34 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/json/JSONTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/json/JSONTest.java @@ -27,6 +27,7 @@ import static org.junit.Assert.assertEquals; +@Deprecated public class JSONTest { static byte[] DEFAULT_BYTES = {3, 12, 14, 41, 12, 2, 3, 12, 4, 67, 23}; static int DEFAULT_$$ = 152; diff --git a/dubbo-demo/dubbo-demo-consumer/pom.xml b/dubbo-demo/dubbo-demo-consumer/pom.xml index 1779534c68b..64565bdc5d7 100644 --- a/dubbo-demo/dubbo-demo-consumer/pom.xml +++ b/dubbo-demo/dubbo-demo-consumer/pom.xml @@ -59,6 +59,10 @@ org.apache.curator curator-framework + + com.alibaba + fastjson + log4j log4j diff --git a/dubbo-demo/dubbo-demo-provider/pom.xml b/dubbo-demo/dubbo-demo-provider/pom.xml index 26210ff7fd9..0ef1177a2d5 100644 --- a/dubbo-demo/dubbo-demo-provider/pom.xml +++ b/dubbo-demo/dubbo-demo-provider/pom.xml @@ -59,6 +59,10 @@ org.apache.curator curator-framework + + com.alibaba + fastjson + log4j log4j diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java index 66fc366e7cd..932633e58f5 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java @@ -17,7 +17,7 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.extension.Activate; -import com.alibaba.dubbo.common.json.JSON; +import com.alibaba.fastjson.JSON; import com.alibaba.dubbo.common.logger.Logger; import com.alibaba.dubbo.common.logger.LoggerFactory; import com.alibaba.dubbo.common.utils.ConcurrentHashSet; @@ -139,7 +139,7 @@ public Result invoke(Invoker invoker, Invocation inv) throws RpcException { sn.append(") "); Object[] args = inv.getArguments(); if (args != null && args.length > 0) { - sn.append(JSON.json(args)); + sn.append(JSON.toJSONString(args)); } String msg = sn.toString(); if (ConfigUtils.isDefault(accesslog)) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java index e1be31fce22..3041baa077e 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java @@ -18,7 +18,7 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.common.extension.ExtensionLoader; -import com.alibaba.dubbo.common.json.JSON; +import com.alibaba.fastjson.JSON; import com.alibaba.dubbo.common.utils.ConfigUtils; import com.alibaba.dubbo.common.utils.PojoUtils; import com.alibaba.dubbo.common.utils.ReflectUtils; @@ -72,11 +72,11 @@ public static Object parseMockValue(String mock, Type[] returnTypes) throws Exce } else if (returnTypes != null && returnTypes.length > 0 && returnTypes[0] == String.class) { value = mock; } else if (StringUtils.isNumeric(mock)) { - value = JSON.parse(mock); + value = JSON.parseObject(mock); } else if (mock.startsWith("{")) { - value = JSON.parse(mock, Map.class); + value = JSON.parseObject(mock, Map.class); } else if (mock.startsWith("[")) { - value = JSON.parse(mock, List.class); + value = JSON.parseObject(mock, List.class); } else { value = mock; } diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java index 30f1eb6ff5f..17484cad3b9 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java @@ -17,7 +17,7 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.extension.Activate; -import com.alibaba.dubbo.common.json.JSON; +import com.alibaba.fastjson.JSON; import com.alibaba.dubbo.common.logger.Logger; import com.alibaba.dubbo.common.logger.LoggerFactory; import com.alibaba.dubbo.common.utils.ConcurrentHashSet; @@ -105,7 +105,7 @@ public Result invoke(Invoker invoker, Invocation invocation) throws RpcExcept channel.send("\r\n" + RpcContext.getContext().getRemoteAddress() + " -> " + invoker.getInterface().getName() + "." + invocation.getMethodName() - + "(" + JSON.json(invocation.getArguments()) + ")" + " -> " + JSON.json(result.getValue()) + + "(" + JSON.toJSONString(invocation.getArguments()) + ")" + " -> " + JSON.toJSONString(result.getValue()) + "\r\nelapsed: " + (end - start) + " ms." + "\r\n\r\n" + prompt); } From 387d9d5d79ec3054538767d1142035e6513a7436 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Wed, 25 Oct 2017 22:12:25 +0800 Subject: [PATCH 05/13] Replace fastjson toJSON() with toJSONString() --- .../dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java index 33a29c33d6b..a8d0e237acb 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java @@ -141,7 +141,7 @@ public String telnet(Channel channel, String message) { long start = System.currentTimeMillis(); Object result = invoker.invoke(new RpcInvocation(invokeMethod, array)).recreate(); long end = System.currentTimeMillis(); - buf.append(JSON.toJSON(result)); + buf.append(JSON.toJSONString(result)); buf.append("\r\nelapsed: "); buf.append(end - start); buf.append(" ms."); From 9f2c9649b1e8cb1a011d635bea6bc4d72a6c3981 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Sun, 22 Oct 2017 18:32:09 +0800 Subject: [PATCH 06/13] Change json to fastjson --- dubbo-common/pom.xml | 1 - .../rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dubbo-common/pom.xml b/dubbo-common/pom.xml index 4ec939b68da..bc4c8db480e 100644 --- a/dubbo-common/pom.xml +++ b/dubbo-common/pom.xml @@ -54,7 +54,6 @@ com.alibaba fastjson - provided org.jvnet.sorcerer diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java index 50a6c763470..33a29c33d6b 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java @@ -16,7 +16,6 @@ package com.alibaba.dubbo.rpc.protocol.dubbo.telnet; import com.alibaba.dubbo.common.extension.Activate; -import com.alibaba.dubbo.common.json.JSON; import com.alibaba.dubbo.common.utils.PojoUtils; import com.alibaba.dubbo.common.utils.ReflectUtils; import com.alibaba.dubbo.common.utils.StringUtils; @@ -28,6 +27,7 @@ import com.alibaba.dubbo.rpc.RpcContext; import com.alibaba.dubbo.rpc.RpcInvocation; import com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol; +import com.alibaba.fastjson.JSON; import java.lang.reflect.Method; import java.util.Collection; @@ -110,7 +110,7 @@ public String telnet(Channel channel, String message) { } List list; try { - list = (List) JSON.parse("[" + args + "]", List.class); + list = JSON.parseArray("[" + args + "]", Object.class); } catch (Throwable t) { return "Invalid json argument, cause: " + t.getMessage(); } @@ -141,7 +141,7 @@ public String telnet(Channel channel, String message) { long start = System.currentTimeMillis(); Object result = invoker.invoke(new RpcInvocation(invokeMethod, array)).recreate(); long end = System.currentTimeMillis(); - buf.append(JSON.json(result)); + buf.append(JSON.toJSON(result)); buf.append("\r\nelapsed: "); buf.append(end - start); buf.append(" ms."); From c5df407881aaff12dc72763bc7d517592b19163b Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Mon, 23 Oct 2017 14:43:57 +0800 Subject: [PATCH 07/13] Fix typo: delete extra semicolon --- .../com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java | 1 - 1 file changed, 1 deletion(-) diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java index 12e4a214539..b26a41fd6bc 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractProxyProtocol.java @@ -35,7 +35,6 @@ public abstract class AbstractProxyProtocol extends AbstractProtocol { private final List> rpcExceptions = new CopyOnWriteArrayList>(); - ; private ProxyFactory proxyFactory; From 3c50ed9d3f44090e107809d900ae1c2696720913 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Mon, 23 Oct 2017 16:22:52 +0800 Subject: [PATCH 08/13] Fix dubbo process detect error in shell script(start.sh dump.sh ...) --- .../src/main/resources/META-INF/assembly/bin/dump.sh | 2 +- .../src/main/resources/META-INF/assembly/bin/start.sh | 6 +++--- .../src/main/resources/META-INF/assembly/bin/stop.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/dump.sh b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/dump.sh index c0e341ae74c..d63098bb1a5 100755 --- a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/dump.sh +++ b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/dump.sh @@ -12,7 +12,7 @@ if [ -z "$SERVER_NAME" ]; then SERVER_NAME=`hostname` fi -PIDS=`ps -ef | grep java | grep "$CONF_DIR" |awk '{print $2}'` +PIDS=`ps -ef | grep java | grep -v grep | grep "$CONF_DIR" |awk '{print $2}'` if [ -z "$PIDS" ]; then echo "ERROR: The $SERVER_NAME does not started!" exit 1 diff --git a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh index 06fd79c3998..ed08cbc3272 100755 --- a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh +++ b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/start.sh @@ -19,7 +19,7 @@ if [ -z "$SERVER_NAME" ]; then SERVER_NAME=`hostname` fi -PIDS=`ps -ef | grep java | grep "$CONF_DIR" |awk '{print $2}'` +PIDS=`ps -ef | grep java | grep -v grep | grep "$CONF_DIR" |awk '{print $2}'` if [ -n "$PIDS" ]; then echo "ERROR: The $SERVER_NAME already started!" echo "PID: $PIDS" @@ -79,7 +79,7 @@ while [ $COUNT -lt 1 ]; do COUNT=`netstat -an | grep $SERVER_PORT | wc -l` fi else - COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l` + COUNT=`ps -f | grep java | grep -v grep | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l` fi if [ $COUNT -gt 0 ]; then break @@ -87,6 +87,6 @@ while [ $COUNT -lt 1 ]; do done echo "OK!" -PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'` +PIDS=`ps -f | grep java | grep -v grep | grep "$DEPLOY_DIR" | awk '{print $2}'` echo "PID: $PIDS" echo "STDOUT: $STDOUT_FILE" diff --git a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/stop.sh b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/stop.sh index 91bbd184606..8fca15e3d64 100755 --- a/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/stop.sh +++ b/dubbo-container/dubbo-container-api/src/main/resources/META-INF/assembly/bin/stop.sh @@ -11,7 +11,7 @@ if [ -z "$SERVER_NAME" ]; then SERVER_NAME=`hostname` fi -PIDS=`ps -ef | grep java | grep "$CONF_DIR" |awk '{print $2}'` +PIDS=`ps -ef | grep java | grep -v grep | grep "$CONF_DIR" |awk '{print $2}'` if [ -z "$PIDS" ]; then echo "ERROR: The $SERVER_NAME does not started!" exit 1 From 9084369c3c79900632b92b415cbaab251ca62a41 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Tue, 24 Oct 2017 17:13:10 +0800 Subject: [PATCH 09/13] Change JSON to fastjson & mark JSON deprecated --- .../alibaba/dubbo/common/json/GenericJSONConverter.java | 1 + .../java/com/alibaba/dubbo/common/json/J2oVisitor.java | 2 +- .../src/main/java/com/alibaba/dubbo/common/json/JSON.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONArray.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONConverter.java | 2 +- .../main/java/com/alibaba/dubbo/common/json/JSONNode.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONObject.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONReader.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONToken.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONVisitor.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSONWriter.java | 2 +- .../com/alibaba/dubbo/common/json/ParseException.java | 2 +- .../main/java/com/alibaba/dubbo/common/json/Yylex.java | 1 + .../common/serialize/support/json/JsonObjectInput.java | 1 + .../common/serialize/support/json/JsonObjectOutput.java | 1 + .../common/serialize/support/json/JsonSerialization.java | 1 + .../java/com/alibaba/dubbo/common/utils/StringUtils.java | 7 +++---- .../com.alibaba.dubbo.common.serialize.Serialization | 1 - .../test/java/com/alibaba/dubbo/common/json/JSONTest.java | 1 + dubbo-demo/dubbo-demo-consumer/pom.xml | 4 ++++ dubbo-demo/dubbo-demo-provider/pom.xml | 4 ++++ .../com/alibaba/dubbo/rpc/filter/AccessLogFilter.java | 4 ++-- .../java/com/alibaba/dubbo/rpc/support/MockInvoker.java | 8 ++++---- .../dubbo/rpc/protocol/dubbo/filter/TraceFilter.java | 4 ++-- 24 files changed, 36 insertions(+), 24 deletions(-) diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java index f0cb594b05d..35542ceb277 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/GenericJSONConverter.java @@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +@Deprecated public class GenericJSONConverter implements JSONConverter { private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; private static final Map, Encoder> GlobalEncoderMap = new HashMap, Encoder>(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java index 2f27395271f..d2b352a9e4b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/J2oVisitor.java @@ -36,7 +36,7 @@ * * @author qian.lei. */ - +@Deprecated class J2oVisitor implements JSONVisitor { public static final boolean[] EMPTY_BOOL_ARRAY = new boolean[0]; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSON.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSON.java index e54f4bad5fc..0cba4a250a3 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSON.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSON.java @@ -29,7 +29,7 @@ * * @author qian.lei */ - +@Deprecated public class JSON { public static final char LBRACE = '{', RBRACE = '}'; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java index 1fc645d23ca..8b96ff1d2c5 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONArray.java @@ -25,7 +25,7 @@ * * @author qian.lei */ - +@Deprecated public class JSONArray implements JSONNode { private List mArray = new ArrayList(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONConverter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONConverter.java index e550c3235e8..c29fcf8e096 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONConverter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONConverter.java @@ -22,7 +22,7 @@ * * @author qianlei */ - +@Deprecated public interface JSONConverter { /** * write object. diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONNode.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONNode.java index 4d546e45fee..aa8531e119f 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONNode.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONNode.java @@ -22,7 +22,7 @@ * * @author qian.lei */ - +@Deprecated interface JSONNode { /** * write json string. diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java index 6b2defde016..680b965171e 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONObject.java @@ -25,7 +25,7 @@ * * @author qian.lei */ - +@Deprecated public class JSONObject implements JSONNode { private Map mMap = new HashMap(); diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONReader.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONReader.java index 4e1728e2993..ae760ebf229 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONReader.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONReader.java @@ -26,7 +26,7 @@ * * @author qian.lei */ - +@Deprecated public class JSONReader { private static ThreadLocal LOCAL_LEXER = new ThreadLocal() { }; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONToken.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONToken.java index 4154b37dcae..bfdab9cf76b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONToken.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONToken.java @@ -20,7 +20,7 @@ * * @author qian.lei */ - +@Deprecated public class JSONToken { // token type public static final int ANY = 0, IDENT = 0x01, LBRACE = 0x02, LSQUARE = 0x03, RBRACE = 0x04, RSQUARE = 0x05, COMMA = 0x06, COLON = 0x07; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONVisitor.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONVisitor.java index 337ecceb642..7c27bd1d1c8 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONVisitor.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONVisitor.java @@ -20,7 +20,7 @@ * * @author qian.lei */ - +@Deprecated public interface JSONVisitor { public static final String CLASS_PROPERTY = "class"; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONWriter.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONWriter.java index ced85f9707a..c62fb09a5b9 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONWriter.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/JSONWriter.java @@ -30,7 +30,7 @@ * * @author qian.lei */ - +@Deprecated public class JSONWriter { private static final byte UNKNOWN = 0, ARRAY = 1, OBJECT = 2, OBJECT_VALUE = 3; private static final String[] CONTROL_CHAR_MAP = new String[]{ diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/ParseException.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/ParseException.java index 64e009cfeb9..6785721550b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/ParseException.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/ParseException.java @@ -20,7 +20,7 @@ * * @author qian.lei */ - +@Deprecated public class ParseException extends Exception { private static final long serialVersionUID = 8611884051738966316L; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/Yylex.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/Yylex.java index 36992aee561..7471a2a83d7 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/Yylex.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/json/Yylex.java @@ -21,6 +21,7 @@ * on 7/3/10 3:12 AM from the specification file * /Users/qianlei/dev/proj/dubbo-1.1/dubbo.common/src/main/java/com/alibaba/dubbo/common/json/json.flex */ +@Deprecated public class Yylex { /** diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java index b2b5c89157a..a250e0dba2b 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectInput.java @@ -35,6 +35,7 @@ * @author william.liangf * @author ding.lid */ +@Deprecated public class JsonObjectInput implements ObjectInput { private final BufferedReader reader; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java index eeb35b63eec..fb9710ed588 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonObjectOutput.java @@ -29,6 +29,7 @@ * * @author william.liangf */ +@Deprecated public class JsonObjectOutput implements ObjectOutput { private final PrintWriter writer; diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java index 7243d9e27a3..585bf50040d 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/serialize/support/json/JsonSerialization.java @@ -29,6 +29,7 @@ * * @author william.liangf */ +@Deprecated public class JsonSerialization implements Serialization { public byte getContentTypeId() { diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java index f4f4436dde8..2926db712f0 100644 --- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java +++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/StringUtils.java @@ -17,11 +17,10 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.io.UnsafeStringWriter; -import com.alibaba.dubbo.common.json.JSON; +import com.alibaba.fastjson.JSON; import com.alibaba.dubbo.common.logger.Logger; import com.alibaba.dubbo.common.logger.LoggerFactory; -import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; @@ -420,8 +419,8 @@ public static String toArgumentString(Object[] args) { buf.append(arg); } else { try { - buf.append(JSON.json(arg)); - } catch (IOException e) { + buf.append(JSON.toJSONString(arg)); + } catch (Exception e) { logger.warn(e.getMessage(), e); buf.append(arg); } diff --git a/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization b/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization index ca493e45799..01fb3035124 100644 --- a/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization +++ b/dubbo-common/src/main/resources/META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization @@ -2,6 +2,5 @@ dubbo=com.alibaba.dubbo.common.serialize.support.dubbo.DubboSerialization hessian2=com.alibaba.dubbo.common.serialize.support.hessian.Hessian2Serialization java=com.alibaba.dubbo.common.serialize.support.java.JavaSerialization compactedjava=com.alibaba.dubbo.common.serialize.support.java.CompactedJavaSerialization -json=com.alibaba.dubbo.common.serialize.support.json.JsonSerialization fastjson=com.alibaba.dubbo.common.serialize.support.json.FastJsonSerialization nativejava=com.alibaba.dubbo.common.serialize.support.nativejava.NativeJavaSerialization \ No newline at end of file diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/json/JSONTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/json/JSONTest.java index 1099c9d151d..eb846ea3f34 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/json/JSONTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/json/JSONTest.java @@ -27,6 +27,7 @@ import static org.junit.Assert.assertEquals; +@Deprecated public class JSONTest { static byte[] DEFAULT_BYTES = {3, 12, 14, 41, 12, 2, 3, 12, 4, 67, 23}; static int DEFAULT_$$ = 152; diff --git a/dubbo-demo/dubbo-demo-consumer/pom.xml b/dubbo-demo/dubbo-demo-consumer/pom.xml index 1779534c68b..64565bdc5d7 100644 --- a/dubbo-demo/dubbo-demo-consumer/pom.xml +++ b/dubbo-demo/dubbo-demo-consumer/pom.xml @@ -59,6 +59,10 @@ org.apache.curator curator-framework + + com.alibaba + fastjson + log4j log4j diff --git a/dubbo-demo/dubbo-demo-provider/pom.xml b/dubbo-demo/dubbo-demo-provider/pom.xml index 26210ff7fd9..0ef1177a2d5 100644 --- a/dubbo-demo/dubbo-demo-provider/pom.xml +++ b/dubbo-demo/dubbo-demo-provider/pom.xml @@ -59,6 +59,10 @@ org.apache.curator curator-framework + + com.alibaba + fastjson + log4j log4j diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java index 66fc366e7cd..932633e58f5 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/filter/AccessLogFilter.java @@ -17,7 +17,7 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.extension.Activate; -import com.alibaba.dubbo.common.json.JSON; +import com.alibaba.fastjson.JSON; import com.alibaba.dubbo.common.logger.Logger; import com.alibaba.dubbo.common.logger.LoggerFactory; import com.alibaba.dubbo.common.utils.ConcurrentHashSet; @@ -139,7 +139,7 @@ public Result invoke(Invoker invoker, Invocation inv) throws RpcException { sn.append(") "); Object[] args = inv.getArguments(); if (args != null && args.length > 0) { - sn.append(JSON.json(args)); + sn.append(JSON.toJSONString(args)); } String msg = sn.toString(); if (ConfigUtils.isDefault(accesslog)) { diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java index 15133b2fa40..cd4e35d5037 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java @@ -18,7 +18,7 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.common.extension.ExtensionLoader; -import com.alibaba.dubbo.common.json.JSON; +import com.alibaba.fastjson.JSON; import com.alibaba.dubbo.common.utils.ConfigUtils; import com.alibaba.dubbo.common.utils.PojoUtils; import com.alibaba.dubbo.common.utils.ReflectUtils; @@ -72,11 +72,11 @@ public static Object parseMockValue(String mock, Type[] returnTypes) throws Exce } else if (returnTypes != null && returnTypes.length > 0 && returnTypes[0] == String.class) { value = mock; } else if (StringUtils.isNumeric(mock)) { - value = JSON.parse(mock); + value = JSON.parseObject(mock); } else if (mock.startsWith("{")) { - value = JSON.parse(mock, Map.class); + value = JSON.parseObject(mock, Map.class); } else if (mock.startsWith("[")) { - value = JSON.parse(mock, List.class); + value = JSON.parseObject(mock, List.class); } else { value = mock; } diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java index 30f1eb6ff5f..17484cad3b9 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/filter/TraceFilter.java @@ -17,7 +17,7 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.extension.Activate; -import com.alibaba.dubbo.common.json.JSON; +import com.alibaba.fastjson.JSON; import com.alibaba.dubbo.common.logger.Logger; import com.alibaba.dubbo.common.logger.LoggerFactory; import com.alibaba.dubbo.common.utils.ConcurrentHashSet; @@ -105,7 +105,7 @@ public Result invoke(Invoker invoker, Invocation invocation) throws RpcExcept channel.send("\r\n" + RpcContext.getContext().getRemoteAddress() + " -> " + invoker.getInterface().getName() + "." + invocation.getMethodName() - + "(" + JSON.json(invocation.getArguments()) + ")" + " -> " + JSON.json(result.getValue()) + + "(" + JSON.toJSONString(invocation.getArguments()) + ")" + " -> " + JSON.toJSONString(result.getValue()) + "\r\nelapsed: " + (end - start) + " ms." + "\r\n\r\n" + prompt); } From 05a8f1ad8efee2fc130019451f3a0ddae73f81a4 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Wed, 25 Oct 2017 22:12:25 +0800 Subject: [PATCH 10/13] Replace fastjson toJSON() with toJSONString() --- .../dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java index 33a29c33d6b..a8d0e237acb 100644 --- a/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java +++ b/dubbo-rpc/dubbo-rpc-default/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java @@ -141,7 +141,7 @@ public String telnet(Channel channel, String message) { long start = System.currentTimeMillis(); Object result = invoker.invoke(new RpcInvocation(invokeMethod, array)).recreate(); long end = System.currentTimeMillis(); - buf.append(JSON.toJSON(result)); + buf.append(JSON.toJSONString(result)); buf.append("\r\nelapsed: "); buf.append(end - start); buf.append(" ms."); From f4e14e8c4cf778d6a23b3f9d4db0dbdb4210df06 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Thu, 26 Oct 2017 10:34:02 +0800 Subject: [PATCH 11/13] Fix unit test ConfigUtilsTest --- .../alibaba/dubbo/common/utils/ConfigUtilsTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ConfigUtilsTest.java b/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ConfigUtilsTest.java index 67169af3d0d..14bd4af501a 100644 --- a/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ConfigUtilsTest.java +++ b/dubbo-common/src/test/java/com/alibaba/dubbo/common/utils/ConfigUtilsTest.java @@ -48,8 +48,8 @@ public static List toArray(T... args) { @Test public void testMergeValues() { List merged = ConfigUtils.mergeValues(Serialization.class, "aaa,bbb,default.cunstom", - toArray("dubbo", "default.hessian2", "json")); - Assert.assertEquals(toArray("dubbo", "json", "aaa", "bbb", "default.cunstom"), merged); + toArray("dubbo", "default.hessian2", "fastjson")); + Assert.assertEquals(toArray("dubbo", "fastjson", "aaa", "bbb", "default.cunstom"), merged); } /** @@ -58,8 +58,8 @@ public void testMergeValues() { @Test public void testMergeValues_addDefault() { List merged = ConfigUtils.mergeValues(Serialization.class, "aaa,bbb,default,zzz", - toArray("dubbo", "default.hessian2", "json")); - Assert.assertEquals(toArray("aaa", "bbb", "dubbo", "json", "zzz"), merged); + toArray("dubbo", "default.hessian2", "fastjson")); + Assert.assertEquals(toArray("aaa", "bbb", "dubbo", "fastjson", "zzz"), merged); } /** @@ -85,8 +85,8 @@ public void testMergeValuesDeleteDefault_2() { */ @Test public void testMergeValuesDelete() { - List merged = ConfigUtils.mergeValues(Serialization.class, "-dubbo,aaa", toArray("dubbo", "default.hessian2", "json")); - Assert.assertEquals(toArray("json", "aaa"), merged); + List merged = ConfigUtils.mergeValues(Serialization.class, "-dubbo,aaa", toArray("dubbo", "default.hessian2", "fastjson")); + Assert.assertEquals(toArray("fastjson", "aaa"), merged); } @Test From 8de5ff2abf2a3756fe8e3674fe409cf0227b62b2 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Thu, 26 Oct 2017 11:33:11 +0800 Subject: [PATCH 12/13] Fix fastjson: use parse() to parse numeric string --- .../main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java index cd4e35d5037..91e54c895e6 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java @@ -18,7 +18,6 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.common.extension.ExtensionLoader; -import com.alibaba.fastjson.JSON; import com.alibaba.dubbo.common.utils.ConfigUtils; import com.alibaba.dubbo.common.utils.PojoUtils; import com.alibaba.dubbo.common.utils.ReflectUtils; @@ -30,6 +29,7 @@ import com.alibaba.dubbo.rpc.RpcException; import com.alibaba.dubbo.rpc.RpcInvocation; import com.alibaba.dubbo.rpc.RpcResult; +import com.alibaba.fastjson.JSON; import java.lang.reflect.Constructor; import java.lang.reflect.Type; @@ -72,7 +72,7 @@ public static Object parseMockValue(String mock, Type[] returnTypes) throws Exce } else if (returnTypes != null && returnTypes.length > 0 && returnTypes[0] == String.class) { value = mock; } else if (StringUtils.isNumeric(mock)) { - value = JSON.parseObject(mock); + value = JSON.parse(mock); } else if (mock.startsWith("{")) { value = JSON.parseObject(mock, Map.class); } else if (mock.startsWith("[")) { From 07dc7dd12cbd86cc905cb7df472a3ab2b19aa4c2 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Thu, 26 Oct 2017 11:37:33 +0800 Subject: [PATCH 13/13] Merge from master --- .../main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java index 3041baa077e..67a97461a0e 100644 --- a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java +++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/MockInvoker.java @@ -18,7 +18,6 @@ import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.common.extension.ExtensionLoader; -import com.alibaba.fastjson.JSON; import com.alibaba.dubbo.common.utils.ConfigUtils; import com.alibaba.dubbo.common.utils.PojoUtils; import com.alibaba.dubbo.common.utils.ReflectUtils; @@ -30,6 +29,7 @@ import com.alibaba.dubbo.rpc.RpcException; import com.alibaba.dubbo.rpc.RpcInvocation; import com.alibaba.dubbo.rpc.RpcResult; +import com.alibaba.fastjson.JSON; import java.lang.reflect.Constructor; import java.lang.reflect.Type; @@ -72,7 +72,7 @@ public static Object parseMockValue(String mock, Type[] returnTypes) throws Exce } else if (returnTypes != null && returnTypes.length > 0 && returnTypes[0] == String.class) { value = mock; } else if (StringUtils.isNumeric(mock)) { - value = JSON.parseObject(mock); + value = JSON.parse(mock); } else if (mock.startsWith("{")) { value = JSON.parseObject(mock, Map.class); } else if (mock.startsWith("[")) {