Skip to content

Commit

Permalink
Merge pull request #6 from apache/master
Browse files Browse the repository at this point in the history
Pull origin
  • Loading branch information
fitzf authored Jun 25, 2019
2 parents 40f1883 + 7285ce9 commit 89fa7d2
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dubbo-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@
<include>org.apache.dubbo:dubbo-serialization-jdk</include>
<include>org.apache.dubbo:dubbo-serialization-protostuff</include>
<include>org.apache.dubbo:dubbo-serialization-gson</include>
<include>org.apache.dubbo:dubbo-serialization-googlePb</include>
<include>org.apache.dubbo:dubbo-serialization-protobuf-json</include>
<include>org.apache.dubbo:dubbo-configcenter-api</include>
<include>org.apache.dubbo:dubbo-configcenter-definition</include>
<include>org.apache.dubbo:dubbo-configcenter-apollo</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@ private static void deserializeInternal(Object result, JavaBeanDescriptor beanDe
for (Map.Entry<Object, Object> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -682,6 +683,24 @@ public void testDateTimeTimestamp() throws Exception {
assertEquals(dateTimeStr, new SimpleDateFormat(dateFormat[0]).format(timestamp));
}

@Test
public void testRealizeCollectionWithNullElement() {
LinkedList<String> listStr = new LinkedList<>();
listStr.add("arrayValue");
listStr.add(null);
HashSet<String> 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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-multicast</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-dubbo</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-multicast</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-dubbo</artifactId>
Expand Down
8 changes: 8 additions & 0 deletions dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-multicast</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-config-spring</artifactId>
Expand Down
8 changes: 8 additions & 0 deletions dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-multicast</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-registry-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-configcenter-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-dubbo</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 89fa7d2

Please sign in to comment.