diff --git a/dubbo-all/pom.xml b/dubbo-all/pom.xml index d8c8949c13e..eaa2dbc92ea 100644 --- a/dubbo-all/pom.xml +++ b/dubbo-all/pom.xml @@ -622,7 +622,7 @@ org.apache.dubbo:dubbo-serialization-jdk org.apache.dubbo:dubbo-serialization-protostuff org.apache.dubbo:dubbo-serialization-gson - org.apache.dubbo:dubbo-serialization-googlePb + org.apache.dubbo:dubbo-serialization-protobuf-json org.apache.dubbo:dubbo-configcenter-api org.apache.dubbo:dubbo-configcenter-definition org.apache.dubbo:dubbo-configcenter-apollo diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtil.java b/dubbo-common/src/main/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtil.java index 995965ac74a..1ce5c455cf5 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtil.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/beanutil/JavaBeanSerializeUtil.java @@ -237,12 +237,12 @@ private static void deserializeInternal(Object result, JavaBeanDescriptor beanDe for (Map.Entry entry : beanDescriptor) { Object key = entry.getKey(); Object value = entry.getValue(); - if (key != null && key instanceof JavaBeanDescriptor) { + if (key instanceof JavaBeanDescriptor) { JavaBeanDescriptor keyDescriptor = (JavaBeanDescriptor) entry.getKey(); key = instantiateForDeserialize(keyDescriptor, loader, cache); deserializeInternal(key, keyDescriptor, loader, cache); } - if (value != null && value instanceof JavaBeanDescriptor) { + if (value instanceof JavaBeanDescriptor) { JavaBeanDescriptor valueDescriptor = (JavaBeanDescriptor) entry.getValue(); value = instantiateForDeserialize(valueDescriptor, loader, cache); deserializeInternal(value, valueDescriptor, loader, cache); diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/json/JSONArray.java b/dubbo-common/src/main/java/org/apache/dubbo/common/json/JSONArray.java index f5e039c3be8..a75bedbdd40 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/json/JSONArray.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/json/JSONArray.java @@ -47,7 +47,7 @@ public Object get(int index) { */ public boolean getBoolean(int index, boolean def) { Object tmp = mArray.get(index); - return tmp != null && tmp instanceof Boolean ? ((Boolean) tmp).booleanValue() : def; + return tmp instanceof Boolean ? ((Boolean) tmp).booleanValue() : def; } /** @@ -59,7 +59,7 @@ public boolean getBoolean(int index, boolean def) { */ public int getInt(int index, int def) { Object tmp = mArray.get(index); - return tmp != null && tmp instanceof Number ? ((Number) tmp).intValue() : def; + return tmp instanceof Number ? ((Number) tmp).intValue() : def; } /** @@ -71,7 +71,7 @@ public int getInt(int index, int def) { */ public long getLong(int index, long def) { Object tmp = mArray.get(index); - return tmp != null && tmp instanceof Number ? ((Number) tmp).longValue() : def; + return tmp instanceof Number ? ((Number) tmp).longValue() : def; } /** @@ -83,7 +83,7 @@ public long getLong(int index, long def) { */ public float getFloat(int index, float def) { Object tmp = mArray.get(index); - return tmp != null && tmp instanceof Number ? ((Number) tmp).floatValue() : def; + return tmp instanceof Number ? ((Number) tmp).floatValue() : def; } /** @@ -95,7 +95,7 @@ public float getFloat(int index, float def) { */ public double getDouble(int index, double def) { Object tmp = mArray.get(index); - return tmp != null && tmp instanceof Number ? ((Number) tmp).doubleValue() : def; + return tmp instanceof Number ? ((Number) tmp).doubleValue() : def; } /** diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/json/JSONObject.java b/dubbo-common/src/main/java/org/apache/dubbo/common/json/JSONObject.java index 052f35269dd..c04d4e14050 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/json/JSONObject.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/json/JSONObject.java @@ -47,7 +47,7 @@ public Object get(String key) { */ public boolean getBoolean(String key, boolean def) { Object tmp = mMap.get(key); - return tmp != null && tmp instanceof Boolean ? (Boolean) tmp : def; + return tmp instanceof Boolean ? (Boolean) tmp : def; } /** @@ -59,7 +59,7 @@ public boolean getBoolean(String key, boolean def) { */ public int getInt(String key, int def) { Object tmp = mMap.get(key); - return tmp != null && tmp instanceof Number ? ((Number) tmp).intValue() : def; + return tmp instanceof Number ? ((Number) tmp).intValue() : def; } /** @@ -71,7 +71,7 @@ public int getInt(String key, int def) { */ public long getLong(String key, long def) { Object tmp = mMap.get(key); - return tmp != null && tmp instanceof Number ? ((Number) tmp).longValue() : def; + return tmp instanceof Number ? ((Number) tmp).longValue() : def; } /** @@ -83,7 +83,7 @@ public long getLong(String key, long def) { */ public float getFloat(String key, float def) { Object tmp = mMap.get(key); - return tmp != null && tmp instanceof Number ? ((Number) tmp).floatValue() : def; + return tmp instanceof Number ? ((Number) tmp).floatValue() : def; } /** @@ -95,7 +95,7 @@ public float getFloat(String key, float def) { */ public double getDouble(String key, double def) { Object tmp = mMap.get(key); - return tmp != null && tmp instanceof Number ? ((Number) tmp).doubleValue() : def; + return tmp instanceof Number ? ((Number) tmp).doubleValue() : def; } /** diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java index 3bab26134e3..52204acb4dd 100644 --- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java +++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java @@ -366,7 +366,7 @@ private static Object realize0(Object pojo, Class type, Type genericType, fin history.put(pojo, dest); for (Object obj : src) { Type keyType = getGenericClassByIndex(genericType, 0); - Class keyClazz = obj.getClass(); + Class keyClazz = obj == null ? null : obj.getClass(); if (keyType instanceof Class) { keyClazz = (Class) keyType; } diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/PojoUtilsTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/PojoUtilsTest.java index 3595efb99f6..f0ab173b4f8 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/utils/PojoUtilsTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/utils/PojoUtilsTest.java @@ -37,6 +37,7 @@ import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; +import java.util.HashSet; import java.util.Map; import java.util.UUID; @@ -682,6 +683,24 @@ public void testDateTimeTimestamp() throws Exception { assertEquals(dateTimeStr, new SimpleDateFormat(dateFormat[0]).format(timestamp)); } + @Test + public void testRealizeCollectionWithNullElement() { + LinkedList listStr = new LinkedList<>(); + listStr.add("arrayValue"); + listStr.add(null); + HashSet setStr = new HashSet<>(); + setStr.add("setValue"); + setStr.add(null); + + Object listResult = PojoUtils.realize(listStr, LinkedList.class); + assertEquals(LinkedList.class, listResult.getClass()); + assertEquals(listResult, listStr); + + Object setResult = PojoUtils.realize(setStr, HashSet.class); + assertEquals(HashSet.class, setResult.getClass()); + assertEquals(setResult, setStr); + } + public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml index c13bc265bc2..c8f9d9d50e1 100644 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml +++ b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/pom.xml @@ -42,6 +42,14 @@ org.apache.dubbo dubbo-registry-multicast + + org.apache.dubbo + dubbo-registry-zookeeper + + + org.apache.dubbo + dubbo-configcenter-zookeeper + org.apache.dubbo dubbo-rpc-dubbo diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml index 4f164bce61e..02d0248e431 100644 --- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml +++ b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-provider/pom.xml @@ -43,6 +43,14 @@ org.apache.dubbo dubbo-registry-multicast + + org.apache.dubbo + dubbo-registry-zookeeper + + + org.apache.dubbo + dubbo-configcenter-zookeeper + org.apache.dubbo dubbo-rpc-dubbo diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml index 4dfde790cfa..5720551e7db 100644 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml +++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml @@ -38,6 +38,14 @@ org.apache.dubbo dubbo-registry-multicast + + org.apache.dubbo + dubbo-registry-zookeeper + + + org.apache.dubbo + dubbo-configcenter-zookeeper + org.apache.dubbo dubbo-config-spring diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml index a93c41ccf00..c683235834a 100644 --- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml +++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml @@ -40,6 +40,14 @@ org.apache.dubbo dubbo-registry-multicast + + org.apache.dubbo + dubbo-registry-zookeeper + + + org.apache.dubbo + dubbo-configcenter-zookeeper + org.apache.dubbo dubbo-rpc-dubbo diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/ProviderInvokerWrapper.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/ProviderInvokerWrapper.java index ce079b743e4..a1eaad3410d 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/ProviderInvokerWrapper.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/ProviderInvokerWrapper.java @@ -90,7 +90,7 @@ public void setReg(boolean reg) { @Override public boolean equals(Object o) { - if (o == null || !(o instanceof ProviderInvokerWrapper)) { + if (!(o instanceof ProviderInvokerWrapper)) { return false; } ProviderInvokerWrapper other = (ProviderInvokerWrapper) o; diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyHelper.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyHelper.java index ec73094ce95..64f41b2daef 100644 --- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyHelper.java +++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyHelper.java @@ -27,7 +27,7 @@ final class NettyHelper { public static void setNettyLoggerFactory() { InternalLoggerFactory factory = InternalLoggerFactory.getDefaultFactory(); - if (factory == null || !(factory instanceof DubboLoggerFactory)) { + if (!(factory instanceof DubboLoggerFactory)) { InternalLoggerFactory.setDefaultFactory(new DubboLoggerFactory()); } } diff --git a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/DubboTelnetDecodeTest.java b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/DubboTelnetDecodeTest.java index e54d2e6508a..28c49cce497 100644 --- a/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/DubboTelnetDecodeTest.java +++ b/dubbo-rpc/dubbo-rpc-dubbo/src/test/java/org/apache/dubbo/rpc/protocol/dubbo/decode/DubboTelnetDecodeTest.java @@ -452,7 +452,7 @@ private ByteBuf createDubboByteBuf() throws IOException { } private static boolean checkTelnetDecoded(Object msg) { - if (msg != null && msg instanceof String && !msg.toString().contains("Unsupported command:")) { + if (msg instanceof String && !msg.toString().contains("Unsupported command:")) { return true; } return false;