diff --git a/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java b/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java index 5b510482d..99c31906e 100644 --- a/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java +++ b/src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java @@ -72,6 +72,11 @@ public DefaultSerializer(@Nonnull final ILogger logger) { /** * Creates a DefaultSerializer with an option to enable serializing of the null values. * + * Serializing of null values can have side effects on the service behavior. + * Sending null values in a PATCH request might reset existing values on the service side. + * Sending null values in a POST request might prevent the service from assigning default values to the properties. + * It is not recommended to send null values to the service in general and this setting should only be used when serializing information for a local store. + * * @param logger the logger * @param serializeNulls the setting of whether or not to serialize the null values in the JSON object */ diff --git a/src/main/java/com/microsoft/graph/serializer/GsonFactory.java b/src/main/java/com/microsoft/graph/serializer/GsonFactory.java index 645766f55..4b305e5ae 100644 --- a/src/main/java/com/microsoft/graph/serializer/GsonFactory.java +++ b/src/main/java/com/microsoft/graph/serializer/GsonFactory.java @@ -78,6 +78,11 @@ public static Gson getGsonInstance(@Nonnull final ILogger logger) { /** * Creates an instance of GSON * + * Serializing of null values can have side effects on the service behavior. + * Sending null values in a PATCH request might reset existing values on the service side. + * Sending null values in a POST request might prevent the service from assigning default values to the properties. + * It is not recommended to send null values to the service in general and this setting should only be used when serializing information for a local store. + * * @param logger the logger * @param serializeNulls the setting of whether or not to serialize the null values in the JSON object * @return the new instance diff --git a/src/test/java/com/microsoft/graph/http/CoreHttpProviderTests.java b/src/test/java/com/microsoft/graph/http/CoreHttpProviderTests.java index ef5035482..43b8ebe76 100644 --- a/src/test/java/com/microsoft/graph/http/CoreHttpProviderTests.java +++ b/src/test/java/com/microsoft/graph/http/CoreHttpProviderTests.java @@ -56,13 +56,13 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class CoreHttpProviderTests { +class CoreHttpProviderTests { private CoreHttpProvider mProvider; private Gson GSON = new GsonBuilder().create(); @Test - public void testErrorResponse() throws Exception { + void testErrorResponse() throws Exception { final GraphErrorCodes expectedErrorCode = GraphErrorCodes.INVALID_REQUEST; final String expectedMessage = "Test error!"; final GraphErrorResponse toSerialize = new GraphErrorResponse(); @@ -85,7 +85,7 @@ public void testErrorResponse() throws Exception { } @Test - public void testVerboseErrorResponse() throws Exception { + void testVerboseErrorResponse() throws Exception { final GraphErrorCodes expectedErrorCode = GraphErrorCodes.INVALID_REQUEST; final String expectedMessage = "Test error!"; final GraphErrorResponse toSerialize = new GraphErrorResponse(); @@ -119,25 +119,25 @@ public void testVerboseErrorResponse() throws Exception { } @Test - public void testHasHeaderReturnsTrue() { + void testHasHeaderReturnsTrue() { HeaderOption h = new HeaderOption("name", "value"); assertTrue(CoreHttpProvider.hasHeader(Arrays.asList(h), "name")); } @Test - public void testHasHeaderReturnsTrueWhenDifferentCase() { + void testHasHeaderReturnsTrueWhenDifferentCase() { HeaderOption h = new HeaderOption("name", "value"); assertTrue(CoreHttpProvider.hasHeader(Arrays.asList(h), "NAME")); } @Test - public void testHasHeaderReturnsFalse() { + void testHasHeaderReturnsFalse() { HeaderOption h = new HeaderOption("name", "value"); assertFalse(CoreHttpProvider.hasHeader(Arrays.asList(h), "blah")); } @Test - public void testStreamToStringReturnsData() { + void testStreamToStringReturnsData() { String data = GSON.toJson(Maps.newHashMap( ImmutableMap.builder() .put("key", "value") @@ -149,14 +149,14 @@ public void testStreamToStringReturnsData() { } @Test - public void testStreamToStringReturnsEmpty() { + void testStreamToStringReturnsEmpty() { final InputStream inputStream = new ByteArrayInputStream(new byte[0]); String convertedData = CoreHttpProvider.streamToString(inputStream); assertEquals("", convertedData); } @Test - public void emptyPostContentTypeIsNotReset() { + void emptyPostContentTypeIsNotReset() { final String contentTypeValue = "application/json"; final HeaderOption ctype = new HeaderOption("Content-Type", contentTypeValue); final ArrayList