Skip to content

Commit

Permalink
Backport #541 fix in 2.4 (for 2.4.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 16, 2014
1 parent 2e8cf4f commit 9a11fb9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Version: 2.4.3 (xx-xxx-2014)
(reported by Ian B, tea-dragon@github)
#524: @JsonIdentityReference(alwaysAsId = true) Custom resolver is reset to SimpleObjectIdResolver
(reported by pkokorev@github)
#541: @JsonProperty in @JsonCreator is conflicting with POJOs getters/attributes
(reported by fabienrenaud@github)
#543: Problem resolving self-referential generic types
- Fixed a problem with `acceptJsonFormatVisitor` with Collection/array types that
are marked with `@JsonValue`; could cause NPE in JSON Schema generator module.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,11 @@ private void _explode(Collection<PropertyName> newNames,
for (Linked<?> node = accessors; node != null; node = node.next) {
PropertyName name = node.name;
if (!node.isNameExplicit || name == null) { // no explicit name -- problem!
// [Issue#541] ... but only as long as it's visible
if (!node.isVisible) {
continue;
}

throw new IllegalStateException("Conflicting/ambiguous property name definitions (implicit name '"
+_name+"'): found multiple explicit names: "
+newNames+", but also implicit accessor: "+node);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.fasterxml.jackson.databind.introspect;

import com.fasterxml.jackson.annotation.*;

import com.fasterxml.jackson.core.JsonProcessingException;

import com.fasterxml.jackson.databind.*;

/**
Expand Down Expand Up @@ -62,6 +65,21 @@ public void _stuff(String value) {
}
}

// For [Issue#541]
static class Bean541 {
protected String str;

@JsonCreator
public Bean541(@JsonProperty("str") String str) {
this.str = str;
}

@JsonProperty("s")
public String getStr() {
return str;
}
}

/*
/**********************************************************
/* Test methods
Expand Down Expand Up @@ -110,4 +128,23 @@ public void testInferredNameConflictsWithSetters() throws Exception
Infernal inf = mapper.readValue(aposToQuotes("{'stuff':'Bob'}"), Infernal.class);
assertNotNull(inf);
}

public void testIssue541() throws Exception {
final ObjectMapper mapper = new ObjectMapper();
mapper.disable(
MapperFeature.AUTO_DETECT_CREATORS,
MapperFeature.AUTO_DETECT_FIELDS,
MapperFeature.AUTO_DETECT_GETTERS,
MapperFeature.AUTO_DETECT_IS_GETTERS,
MapperFeature.AUTO_DETECT_SETTERS,
MapperFeature.USE_GETTERS_AS_SETTERS
);
Bean541 data = mapper.readValue("{\"str\":\"the string\"}", Bean541.class);
if (data == null) {
throw new IllegalStateException("data is null");
}
if (!"the string".equals(data.getStr())) {
throw new IllegalStateException("bad value for data.str");
}
}
}

0 comments on commit 9a11fb9

Please sign in to comment.