Skip to content

Commit

Permalink
Process TypeDefinition#properties when it is not a primitive type obj…
Browse files Browse the repository at this point in the history
…ect (#7579)

* process TypeDefinition#properties when necessary

* Fix code-style check
  • Loading branch information
BurningCN committed May 18, 2021
1 parent d476c5d commit 1a7ca1e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import java.util.Map;
import java.util.Set;

import static org.apache.dubbo.common.utils.ClassUtils.isSimpleType;

/**
* 2015/1/27.
*/
Expand All @@ -55,9 +53,6 @@ public static TypeDefinition build(Type type, Class<?> clazz, Map<Class<?>, Type
td = DefaultTypeBuilder.build(clazz, typeCache);
td.setTypeBuilderName(DefaultTypeBuilder.class.getName());
}
if (isSimpleType(clazz)) { // changed since 2.7.6
td.setProperties(null);
}
return td;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.List;
import java.util.Map;

import static org.apache.dubbo.common.utils.ClassUtils.isSimpleType;

/**
* 2015/1/27.
*/
Expand All @@ -51,14 +53,16 @@ public static TypeDefinition build(Class<?> clazz, Map<Class<?>, TypeDefinition>
ref.set$ref(name);
typeCache.put(clazz, ref);

List<Field> fields = ClassUtils.getNonStaticFields(clazz);
for (Field field : fields) {
String fieldName = field.getName();
Class<?> fieldClass = field.getType();
Type fieldType = field.getGenericType();
if(!clazz.isPrimitive() && !isSimpleType(clazz)){
List<Field> fields = ClassUtils.getNonStaticFields(clazz);
for (Field field : fields) {
String fieldName = field.getName();
Class<?> fieldClass = field.getType();
Type fieldType = field.getGenericType();

TypeDefinition fieldTd = TypeDefinitionBuilder.build(fieldType, fieldClass, typeCache);
td.getProperties().put(fieldName, fieldTd);
TypeDefinition fieldTd = TypeDefinitionBuilder.build(fieldType, fieldClass, typeCache);
td.getProperties().put(fieldName, fieldTd);
}
}

typeCache.put(clazz, td);
Expand Down

0 comments on commit 1a7ca1e

Please sign in to comment.