ijokarumawak commented on a change in pull request #3504: NIFI-6318: Support EL
in CSV formatting properties
URL: https://github.com/apache/nifi/pull/3504#discussion_r305188011
##########
File path:
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/csv/CSVRecordSetWriter.java
##########
@@ -64,14 +70,28 @@
}
@OnEnabled
- public void storeCsvFormat(final ConfigurationContext context) {
- this.csvFormat = CSVUtils.createCSVFormat(context);
+ public void storeStaticProperties(final ConfigurationContext context) {
+ this.context = context;
+
this.includeHeader =
context.getProperty(CSVUtils.INCLUDE_HEADER_LINE).asBoolean();
this.charSet = context.getProperty(CSVUtils.CHARSET).getValue();
+
+ if (!CSVUtils.isDynamicCSVFormat(context)) {
+ this.csvFormat = CSVUtils.createCSVFormat(context,
Collections.emptyMap());
+ } else {
+ this.csvFormat = null;
+ }
}
@Override
- public RecordSetWriter createWriter(final ComponentLog logger, final
RecordSchema schema, final OutputStream out) throws SchemaNotFoundException,
IOException {
+ public RecordSetWriter createWriter(final ComponentLog logger, final
RecordSchema schema, final OutputStream out, final Map<String, String>
variables) throws SchemaNotFoundException, IOException {
+ CSVFormat csvFormat;
+ if (!CSVUtils.isDynamicCSVFormat(context)) {
+ csvFormat = this.csvFormat;
+ } else {
+ csvFormat = CSVUtils.createCSVFormat(context, variables);
+ }
Review comment:
Since `this.csvFormat` is the result of `CSVUtils.isDynamicCSVFormat()`, we
can replace this if statement to a simpler one:
```
if (!this.csvFormat != null) {
```
----------------------------------------------------------------
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]
With regards,
Apache Git Services