diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java index 525e0fd129..94428fb67a 100644 --- a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java +++ b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java @@ -403,18 +403,18 @@ protected void collectAll() property.mergeAnnotations(_forSerialization); } - // And use custom naming strategy, if applicable... - PropertyNamingStrategy naming = _findNamingStrategy(); - if (naming != null) { - _renameUsing(props, naming); - } - // Sort by visibility (explicit over implicit); drop all but first of member // type (getter, setter etc) if there is visibility difference for (POJOPropertyBuilder property : props.values()) { property.trimByVisibility(); } + // And use custom naming strategy, if applicable... + PropertyNamingStrategy naming = _findNamingStrategy(); + if (naming != null) { + _renameUsing(props, naming); + } + // and, if required, apply wrapper name: note, MUST be done after // annotations are merged. if (_config.isEnabled(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME)) { diff --git a/src/test/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollectorTest.java b/src/test/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollectorTest.java index 4bb7aa1aa5..e4082afcc2 100644 --- a/src/test/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollectorTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollectorTest.java @@ -231,6 +231,15 @@ public DuplicateGetterCreatorBean(@JsonProperty("bloop") @A boolean bloop) {} public boolean getBloop() { return true; } } + static class DuplicateSetterBean { + public void setBloop(Boolean bloop) { + } + + @JsonSetter + public void setBloop(Object bloop) { + } + } + /* /********************************************************** /* Unit tests @@ -493,6 +502,26 @@ public void testDuplicateGettersCreator() throws Exception assertTrue(prop._getters.next.value.hasAnnotation(A.class)); } + public void testDuplicateSetters() throws Exception { + POJOPropertiesCollector coll = collector(MAPPER, DuplicateSetterBean.class, true); + List props = coll.getProperties(); + assertEquals(1, props.size()); + BeanPropertyDefinition prop = props.get(0); + assertEquals("bloop", prop.getName()); + assertEquals(prop.getSetter().getRawParameterType(0), Object.class); + } + + public void testDuplicateSettersHaveCustomNamingStrategy() throws Exception { + ObjectMapper mapper = newJsonMapper(); + mapper.setPropertyNamingStrategy(PropertyNamingStrategies.LOWER_CAMEL_CASE); + POJOPropertiesCollector coll = collector(mapper, DuplicateSetterBean.class, false); + List props = coll.getProperties(); + assertEquals(1, props.size()); + BeanPropertyDefinition prop = props.get(0); + assertEquals("bloop", prop.getName()); + assertEquals(prop.getSetter().getRawParameterType(0), Object.class); + } + private void _verifyProperty(BeanDescription beanDesc, boolean verifyDesc, boolean verifyIndex, String expDefaultValue) {