diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java index 492c58610..6892affad 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java @@ -250,7 +250,8 @@ public class ODataJsonDeserializer implements ODataDeserializer { EntitySetImpl inlineEntitySet = new EntitySetImpl(); inlineEntitySet.getEntities().addAll(consumeEntitySetArray(edmNavigationProperty.getType(), jsonNode)); link.setInlineEntitySet(inlineEntitySet); - } else if (!jsonNode.isArray() && !jsonNode.isValueNode() && !edmNavigationProperty.isCollection()) { + } else if (!jsonNode.isArray() && (!jsonNode.isValueNode() || jsonNode.isNull()) + && !edmNavigationProperty.isCollection()) { link.setType(ODataLinkType.ENTITY_NAVIGATION.toString()); if (!jsonNode.isNull()) { Entity inlineEntity = consumeEntityNode(edmNavigationProperty.getType(), (ObjectNode) jsonNode); diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java index 417e37101..f2a65cdf1 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataDeserializerDeepInsertTest.java @@ -121,7 +121,25 @@ public class ODataDeserializerDeepInsertTest extends AbstractODataDeserializerTe throw e; } } - + + @Test + public void expandedToOneValidNullValue() throws Exception { + String entityString = + "{\"PropertyInt16\":32767," + + "\"NavPropertyETAllPrimOne\":null" + + "}"; + InputStream stream = new ByteArrayInputStream(entityString.getBytes()); + EdmEntityType edmEntityType = edm.getEntityType(new FullQualifiedName("Namespace1_Alias", "ETTwoPrim")); + final Entity entity = OData.newInstance().createDeserializer(ODataFormat.JSON).entity(stream, edmEntityType); + + assertEquals(1, entity.getNavigationLinks().size()); + final Link link = entity.getNavigationLinks().get(0); + + assertEquals("NavPropertyETAllPrimOne", link.getTitle()); + assertNull(link.getInlineEntity()); + assertNull(link.getInlineEntitySet()); + } + @Test(expected = DeserializerException.class) public void expandedToOneInvalidStringValue() throws Exception { String entityString =