ChrisSamo632 commented on a change in pull request #4755:
URL: https://github.com/apache/nifi/pull/4755#discussion_r565542497



##########
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:
       @mattyb149 managed to confirm that this is a problem for my flow in 
1.11.4 when outputting data to Elasticsearch that is a Record containing nested 
Records with Arrays or Records in them... the fields within the nested Records 
come through as `null` when that's not wanted. If it makes a difference, we're 
using Avro as the data format between processors in this Flow.
   
   I think the logic in PutElasticsearchRecord is missing an if-else to handle 
`Object[]` as well as `List` and/or other structures (the `DataTypeUtils` to 
convert between NiFi Record structure and "plain" Java Objects is a little 
flawed with some of these conversions - I've recently raised separate Jira 
tickets documenting some of those).
   
   The switch to using the Jackson-based null/empty suppression should allow 
for better null field control.




----------------------------------------------------------------
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]


Reply via email to