From 9fa7b900fd916632036b747a1cf8f1e4f650f35e Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Sat, 28 Oct 2017 17:32:44 +0800 Subject: [PATCH] Merge pull request #776 from chickenlj:json_to_fastjson Deprecate internal JSON impl and change to fastjson --- dubbo-common/pom.xml | 1 - .../dubbo/common/json/GenericJSONConverter.java | 1 + .../com/alibaba/dubbo/common/json/J2oVisitor.java | 2 +- .../java/com/alibaba/dubbo/common/json/JSON.java | 2 +- .../com/alibaba/dubbo/common/json/JSONArray.java | 2 +- .../alibaba/dubbo/common/json/JSONConverter.java | 2 +- .../com/alibaba/dubbo/common/json/JSONNode.java | 2 +- .../com/alibaba/dubbo/common/json/JSONObject.java | 2 +- .../com/alibaba/dubbo/common/json/JSONReader.java | 2 +- .../com/alibaba/dubbo/common/json/JSONToken.java | 2 +- .../com/alibaba/dubbo/common/json/JSONVisitor.java | 2 +- .../com/alibaba/dubbo/common/json/JSONWriter.java | 2 +- .../alibaba/dubbo/common/json/ParseException.java | 2 +- .../java/com/alibaba/dubbo/common/json/Yylex.java | 1 + .../serialize/support/json/JsonObjectInput.java | 1 + .../serialize/support/json/JsonObjectOutput.java | 1 + .../serialize/support/json/JsonSerialization.java | 1 + .../alibaba/dubbo/common/utils/StringUtils.java | 7 +++---- ...om.alibaba.dubbo.common.serialize.Serialization | 1 - .../com/alibaba/dubbo/common/json/JSONTest.java | 1 + .../dubbo/common/utils/ConfigUtilsTest.java | 12 ++++++------ .../main/resources/META-INF/assembly/bin/dump.sh | 2 +- .../main/resources/META-INF/assembly/bin/start.sh | 6 +++--- .../main/resources/META-INF/assembly/bin/stop.sh | 2 +- dubbo-demo/dubbo-demo-consumer/pom.xml | 4 ++++ dubbo-demo/dubbo-demo-provider/pom.xml | 4 ++++ .../alibaba/dubbo/rpc/filter/AccessLogFilter.java | 4 ++-- .../dubbo/rpc/protocol/AbstractProxyProtocol.java | 1 - .../com/alibaba/dubbo/rpc/support/MockInvoker.java | 14 +++++++------- .../rpc/protocol/dubbo/filter/TraceFilter.java | 4 ++-- .../protocol/dubbo/telnet/InvokeTelnetHandler.java | 6 +++--- 31 files changed, 53 insertions(+), 43 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-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-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 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 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/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; 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..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.dubbo.common.json.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; @@ -74,9 +74,9 @@ public static Object parseMockValue(String mock, Type[] returnTypes) throws Exce } else if (StringUtils.isNumeric(mock)) { value = JSON.parse(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; } @@ -127,7 +127,7 @@ public Result invoke(Invocation invocation) throws RpcException { Invoker invoker = getInvoker(mock); return invoker.invoke(invocation); } catch (Throwable t) { - throw new RpcException("Failed to create mock implementation class " + mock, t); + throw new RpcException("Failed to create mock implemention class " + mock, t); } } } @@ -166,11 +166,11 @@ private Invoker getInvoker(String mockService) { Class mockClass = ReflectUtils.forName(mockService); if (!serviceType.isAssignableFrom(mockClass)) { - throw new IllegalArgumentException("The mock implementation class " + mockClass.getName() + " not implement interface " + serviceType.getName()); + throw new IllegalArgumentException("The mock implemention class " + mockClass.getName() + " not implement interface " + serviceType.getName()); } if (!serviceType.isAssignableFrom(mockClass)) { - throw new IllegalArgumentException("The mock implementation class " + mockClass.getName() + " not implement interface " + serviceType.getName()); + throw new IllegalArgumentException("The mock implemention class " + mockClass.getName() + " not implement interface " + serviceType.getName()); } try { T mockObject = (T) mockClass.newInstance(); @@ -180,7 +180,7 @@ private Invoker getInvoker(String mockService) { } return invoker; } catch (InstantiationException e) { - throw new IllegalStateException("No such empty constructor \"public " + mockClass.getSimpleName() + "()\" in mock implementation class " + mockClass.getName(), e); + throw new IllegalStateException("No such empty constructor \"public " + mockClass.getSimpleName() + "()\" in mock implemention class " + mockClass.getName(), e); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } 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); } 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..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 @@ -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.toJSONString(result)); buf.append("\r\nelapsed: "); buf.append(end - start); buf.append(" ms.");