Skip to content

Commit f95a927

Browse files
committed
Fix #541 for master (2.5)
1 parent 8667b6d commit f95a927

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,11 @@ private void _explode(Collection<PropertyName> newNames,
857857
for (Linked<?> node = accessors; node != null; node = node.next) {
858858
PropertyName name = node.name;
859859
if (!node.isNameExplicit || name == null) { // no explicit name -- problem!
860+
// [Issue#541] ... but only as long as it's visible
861+
if (!node.isVisible) {
862+
continue;
863+
}
864+
860865
throw new IllegalStateException("Conflicting/ambiguous property name definitions (implicit name '"
861866
+_name+"'): found multiple explicit names: "
862867
+newNames+", but also implicit accessor: "+node);

src/test/java/com/fasterxml/jackson/databind/introspect/TestPropertyConflicts.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.fasterxml.jackson.databind.introspect;
22

3+
import com.fasterxml.jackson.annotation.*;
4+
35
import com.fasterxml.jackson.core.JsonProcessingException;
6+
47
import com.fasterxml.jackson.databind.*;
58

69
/**
@@ -62,6 +65,21 @@ public void _stuff(String value) {
6265
}
6366
}
6467

68+
// For [Issue#541]
69+
static class Bean541 {
70+
protected String str;
71+
72+
@JsonCreator
73+
public Bean541(@JsonProperty("str") String str) {
74+
this.str = str;
75+
}
76+
77+
@JsonProperty("s")
78+
public String getStr() {
79+
return str;
80+
}
81+
}
82+
6583
/*
6684
/**********************************************************
6785
/* Test methods
@@ -110,4 +128,23 @@ public void testInferredNameConflictsWithSetters() throws Exception
110128
Infernal inf = mapper.readValue(aposToQuotes("{'stuff':'Bob'}"), Infernal.class);
111129
assertNotNull(inf);
112130
}
131+
132+
public void testIssue541() throws Exception {
133+
final ObjectMapper mapper = new ObjectMapper();
134+
mapper.disable(
135+
MapperFeature.AUTO_DETECT_CREATORS,
136+
MapperFeature.AUTO_DETECT_FIELDS,
137+
MapperFeature.AUTO_DETECT_GETTERS,
138+
MapperFeature.AUTO_DETECT_IS_GETTERS,
139+
MapperFeature.AUTO_DETECT_SETTERS,
140+
MapperFeature.USE_GETTERS_AS_SETTERS
141+
);
142+
Bean541 data = mapper.readValue("{\"str\":\"the string\"}", Bean541.class);
143+
if (data == null) {
144+
throw new IllegalStateException("data is null");
145+
}
146+
if (!"the string".equals(data.getStr())) {
147+
throw new IllegalStateException("bad value for data.str");
148+
}
149+
}
113150
}

0 commit comments

Comments
 (0)