NIFI-5464: Consider ports invalid unless they have both incoming and outgoing connections

This closes #3417.

Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
Mark Payne 2019-04-08 16:28:58 -04:00 committed by Bryan Bende
parent 49e74b29db
commit 38db4e97cd
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
1 changed files with 16 additions and 8 deletions

View File

@ -50,20 +50,28 @@ public class LocalPort extends AbstractPort {
@Override
public boolean isValid() {
return !getConnections(Relationship.ANONYMOUS).isEmpty();
return !getConnections(Relationship.ANONYMOUS).isEmpty() && hasIncomingConnection();
}
@Override
public Collection<ValidationResult> getValidationErrors() {
final Collection<ValidationResult> validationErrors = new ArrayList<>();
if (!isValid()) {
final ValidationResult error = new ValidationResult.Builder()
.explanation(String.format("Output connection for port '%s' is not defined.", getName()))
.subject(String.format("Port '%s'", getName()))
.valid(false)
.build();
validationErrors.add(error);
if (getConnections(Relationship.ANONYMOUS).isEmpty()) {
validationErrors.add(new ValidationResult.Builder()
.explanation("Port has no outgoing connections")
.subject(String.format("Port '%s'", getName()))
.valid(false)
.build());
}
if (!hasIncomingConnection()) {
validationErrors.add(new ValidationResult.Builder()
.explanation("Port has no incoming connections")
.subject(String.format("Port '%s'", getName()))
.valid(false)
.build());
}
return validationErrors;
}