Skip to content

Commit

Permalink
Fix #541 for master (2.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 16, 2014
1 parent 8667b6d commit f95a927
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,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 f95a927

Please sign in to comment.