ChrisSamo632 commented on a change in pull request #4755:
URL: https://github.com/apache/nifi/pull/4755#discussion_r560474183
##########
File path:
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientServiceImpl.java
##########
@@ -90,6 +93,15 @@ public void onEnabled(final ConfigurationContext context)
throws InitializationE
try {
setupClient(context);
responseCharset =
Charset.forName(context.getProperty(CHARSET).getValue());
+
+ // re-create the ObjectMapper in case the SUPPRESS_NULLS property
has changed - the JsonInclude settings aren't dynamic
+ mapper = new ObjectMapper();
+ if
(ALWAYS_SUPPRESS.getValue().equals(context.getProperty(SUPPRESS_NULLS).getValue()))
{
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
Review comment:
You are correct, I would expect the `"y": null` output when using
`NEVER_SUPPRESS` (but not for `ALWAYS_SUPPRESS`).
I've included this as a test in the `ElasticSearch5ClientService_IT` as
`testNullSuppression`, which involves:
* creating a document with `NEVER_SUPPRESS` that contains and asserts the
inserted document matches:
* "is_null": null
* "is_empty": empty ("")
* "is_blank": blank (" ")
* "msg": "test"
* creating the same document with `ALWAYS_SUPPRESS` then asserting that the
document *does not* contain the `"is_null"` or `"is_empty"` fields
Switching between the two states involves disabling the
`ElasticSearchClientService`, changing the `SUPPRESS_NULLS` property, then
re-enabling the service before using it to to `bulk` index the document then
`get` it back from Elasticsearch.
How are you running the code and checking the output if not via the tests?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]