Skip to content

Commit 413e573

Browse files
committed
Merge branch '2.13' of github.com:FasterXML/jackson-databind into 2.13
2 parents 0588251 + 86dd187 commit 413e573

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializerFactory.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -688,18 +688,19 @@ protected List<BeanPropertyWriter> filterBeanProperties(SerializationConfig conf
688688
protected List<BeanPropertyWriter> filterUnwantedJDKProperties(SerializationConfig config,
689689
BeanDescription beanDesc, List<BeanPropertyWriter> props)
690690
{
691-
// First, only consider something that implement `CharSequence`
691+
// First, only consider something that implements `CharSequence`
692692
if (beanDesc.getType().isTypeOrSubTypeOf(CharSequence.class)) {
693-
Iterator<BeanPropertyWriter> it = props.iterator();
694-
while (it.hasNext()) {
695-
BeanPropertyWriter prop = it.next();
693+
// And only has a single property from "isEmpty()" default method
694+
if (props.size() == 1) {
695+
BeanPropertyWriter prop = props.get(0);
696696
// And only remove property induced by `isEmpty()` method declared
697697
// in `CharSequence` (default implementation)
698+
// (could in theory relax this limit, probably but... should be fine)
698699
AnnotatedMember m = prop.getMember();
699700
if ((m instanceof AnnotatedMethod)
700701
&& "isEmpty".equals(m.getName())
701702
&& m.getDeclaringClass() == CharSequence.class) {
702-
it.remove();
703+
props.remove(0);
703704
}
704705
}
705706
}

0 commit comments

Comments
 (0)