-
-
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.
Merge pull request #598 from herau/597
fix NPE #597
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 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
40 changes: 40 additions & 0 deletions
40
src/test/java/com/fasterxml/jackson/failing/TestNpe597.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,40 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import java.io.IOException; | ||
import java.util.UUID; | ||
|
||
public class TestNpe597 extends BaseMapTest | ||
{ | ||
|
||
static class JsonEntity { | ||
private final String type; | ||
private final UUID id; | ||
|
||
private JsonEntity(String type, UUID id) { | ||
this.type = type; | ||
this.id = id; | ||
} | ||
|
||
@JsonCreator | ||
public static JsonEntity create(@JsonProperty("type") String type, @JsonProperty("id") UUID id) { | ||
if (type != null && !type.contains(" ") && (id != null)) { | ||
return new JsonEntity(type, id); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
|
||
public void testDeserialize() throws IOException { | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
String json = "{ \"type\" : \" \", \"id\" : \"000c0ffb-a0d6-4d2e-a379-4aeaaf283599\" }"; | ||
objectMapper.readValue(json, JsonEntity.class); | ||
} | ||
|
||
} |