pvillard31 commented on a change in pull request #5446:
URL: https://github.com/apache/nifi/pull/5446#discussion_r724160983
##########
File path:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListenHTTP.java
##########
@@ -273,13 +310,40 @@ public AllowableValue getAllowableValue() {
private final AtomicReference<ProcessSessionFactory>
sessionFactoryReference = new AtomicReference<>();
private final AtomicReference<StreamThrottler> throttlerRef = new
AtomicReference<>();
+ private volatile boolean isRecordReaderSet;
+ private volatile boolean isRecordWriterSet;
+
@Override
- protected Collection<ValidationResult> customValidate(ValidationContext
context) {
- List<ValidationResult> results = new ArrayList<>(1);
+ public void onPropertyModified(final PropertyDescriptor descriptor, final
String oldValue, final String newValue) {
+ if (RECORD_READER.equals(descriptor)) {
+ isRecordReaderSet = StringUtils.isNotEmpty(newValue);
+ } else if (RECORD_WRITER.equals(descriptor)) {
+ isRecordWriterSet = StringUtils.isNotEmpty(newValue);
+ }
+ }
- validatePortsAreNotEqual(context, results);
+ @Override
+ protected Collection<ValidationResult> customValidate(ValidationContext
validationContext) {
+ final Set<ValidationResult> validationResults = new
HashSet<>(super.customValidate(validationContext));
+
+ validatePortsAreNotEqual(validationContext, validationResults);
+
+ final String explanation = "%s must be set if %s is set in order to
write FlowFiles as Records.";
+ if (isRecordReaderSet && !isRecordWriterSet) {
+ validationResults.add(new ValidationResult.Builder()
+ .subject(RECORD_WRITER.getName())
+ .explanation(String.format(explanation,
RECORD_WRITER.getDisplayName(), RECORD_READER.getDisplayName()))
+ .valid(false)
+ .build());
+ } else if (isRecordWriterSet && !isRecordReaderSet) {
+ validationResults.add(new ValidationResult.Builder()
+ .subject(RECORD_READER.getName())
+ .explanation(String.format(explanation,
RECORD_READER.getDisplayName(), RECORD_WRITER.getDisplayName()))
+ .valid(false)
+ .build());
Review comment:
I think it'd make sense to have:
- no record reader/writer: current behavior no change
- record reader / no record writer: we just validate the input against a
schema with a reader but we write the data as-is
- record reader + record writer: parsing the data and writing according to
writer configuration
I think the 2nd option cannot be done with the current code. Thoughts?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]