-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba35c17
commit 277151d
Showing
4 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/test/java/com/fasterxml/jackson/databind/deser/builder/BuilderInfiniteLoop1978Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.fasterxml.jackson.databind.deser.builder; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonUnwrapped; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
|
||
public class BuilderInfiniteLoop1978Test extends BaseMapTest | ||
{ | ||
static class Builder | ||
{ | ||
private SubBean temp; | ||
private int id; | ||
|
||
Builder(@JsonProperty("beanId") int beanId) { | ||
this.id = beanId; | ||
} | ||
|
||
@JsonUnwrapped(prefix="sub.") | ||
public Builder withThing(SubBean thing) { | ||
this.temp = thing; | ||
return this; | ||
} | ||
|
||
public Bean build() | ||
{ | ||
Bean bean = new Bean(id); | ||
bean.setThing( temp ); | ||
return bean; | ||
} | ||
} | ||
|
||
@JsonDeserialize(builder = Builder.class) | ||
static class Bean | ||
{ | ||
int id; | ||
SubBean thing; | ||
|
||
public Bean(int id) { | ||
this.id = id; | ||
} | ||
|
||
public SubBean getThing() { | ||
return thing; | ||
} | ||
|
||
public void setThing( SubBean thing ) { | ||
this.thing = thing; | ||
} | ||
} | ||
|
||
static class SubBuilder | ||
{ | ||
private int element1; | ||
private String element2; | ||
|
||
@JsonProperty("el1") | ||
public SubBuilder withElement1(int e1) { | ||
this.element1 = e1; | ||
return this; | ||
} | ||
|
||
public SubBean build() | ||
{ | ||
SubBean bean = new SubBean(); | ||
bean.element1 = element1; | ||
bean.element2 = element2; | ||
return bean; | ||
} | ||
} | ||
|
||
@JsonDeserialize(builder = SubBuilder.class) | ||
static class SubBean | ||
{ | ||
public int element1; | ||
public String element2; | ||
} | ||
|
||
/* | ||
/********************************************************************** | ||
/* Test methods | ||
/********************************************************************** | ||
*/ | ||
|
||
// for [databind#1978] | ||
public void testInfiniteLoop1978() throws Exception | ||
{ | ||
String json = "{\"sub.el1\":34,\"sub.el2\":\"some text\"}"; | ||
ObjectMapper mapper = new ObjectMapper(); | ||
Bean bean = mapper.readValue( json, Bean.class ); | ||
assertNotNull(bean); | ||
} | ||
} |