Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ protected T _deserializeWrappedValue(JsonParser p, DeserializationContext ctxt)
T result = (T) handleNestedArrayForSingle(p, ctxt);
return result;
}
if (p.currentToken() == JsonToken.VALUE_NULL) {
return getNullValue(ctxt);
}
return (T) deserialize(p, ctxt);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.fasterxml.jackson.databind.struct;

import java.io.IOException;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Map;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.core.type.TypeReference;
Expand Down Expand Up @@ -78,4 +81,21 @@ public void testEnumMapUnwrapping() throws Exception
verifyException(e, "more than one value");
}
}

@Test
public void testDeserializeArrayWithNullElement() throws IOException {
String json = "{\"value\": [null]}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting + Exception is sort of convention now

Suggested change
public void testDeserializeArrayWithNullElement() throws IOException {
String json = "{\"value\": [null]}";
public void testDeserializeArrayWithNullElement()
throws Exception
{
String json = "{\"value\": [null]}";


ObjectReader r = UNWRAPPING_MAPPER.readerFor(StringWrapper.class);
JsonFactory factory = new JsonFactory();
JsonParser p = factory.createParser(json);
StringWrapper v = r.readValue(p);
assertNotNull(v);
assertNull(v.value);
}


public static class StringWrapper {
public String value;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declarations should go top

}