Skip to content

Commit

Permalink
nacos config serialization ignore null field.
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiyue1102 committed Nov 20, 2024
1 parent 9ef1512 commit 6659309
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.BeansException;
import org.springframework.beans.NotReadablePropertyException;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanPostProcessor;
Expand Down Expand Up @@ -748,10 +749,17 @@ private static String[] getNullPropertyNames(Object source) {
Set<String> nullPropertyNames = new HashSet<>();
for (PropertyDescriptor pd : pds) {
String propertyName = pd.getName();
Object propertyValue = src.getPropertyValue(propertyName);
if (propertyValue == null) {
try {
Object propertyValue = src.getPropertyValue(propertyName);
if (propertyValue == null) {
nullPropertyNames.add(propertyName);
}
}
catch (NotReadablePropertyException e) {
//ignore
nullPropertyNames.add(propertyName);
}

}
return nullPropertyNames.toArray(new String[0]);
}
Expand Down

0 comments on commit 6659309

Please sign in to comment.