Skip to content

Commit

Permalink
Merge pull request #598 from herau/597
Browse files Browse the repository at this point in the history
fix NPE #597
  • Loading branch information
cowtowncoder committed Nov 4, 2014
2 parents 0707a37 + 690af4e commit 0ed8069
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ protected Object _deserializeUsingPropertyBased(final JsonParser jp, final Deser
wrapAndThrow(e, _beanType.getRawClass(), propName, ctxt);
bean = null; // never gets here
}
if (bean == null) {
throw ctxt.instantiationException(_beanType.getRawClass(), " the created object is null");
}
// polymorphic?
if (bean.getClass() != _beanType.getRawClass()) {
return handlePolymorphic(jp, ctxt, bean, unknown);
Expand Down
40 changes: 40 additions & 0 deletions src/test/java/com/fasterxml/jackson/failing/TestNpe597.java
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);
}

}

0 comments on commit 0ed8069

Please sign in to comment.