Program: 37769
Project: 37769
Buggy source:
/** 
 * Checks a flow for endpoints' conflicts.
 * @param requestedFlow a flow to check
 * @throws FlowValidationException is thrown in a case when flow endpoints conflict with existing flows.
 */
public void checkFlowForEndpointConflicts(Flow requestedFlow) throws FlowValidationException {
  Set<Flow> conflictsOnSource;
  if (requestedFlow.getSourceVlan() == 0) {
    conflictsOnSource=flowCache.getFlowsForEndpoint(requestedFlow.getSourceSwitch(),requestedFlow.getSourcePort());
  }
 else {
    conflictsOnSource=flowCache.getFlowsForEndpoint(requestedFlow.getSourceSwitch(),requestedFlow.getSourcePort(),requestedFlow.getSourceVlan());
  }
  Optional<Flow> conflictedFlow=conflictsOnSource.stream().filter(flow -> !flow.getFlowId().equals(requestedFlow.getFlowId())).findAny();
  if (conflictedFlow.isPresent()) {
    throw new FlowValidationException(format("String_Node_Str",requestedFlow.getSourcePort(),requestedFlow.getSourceSwitch(),conflictedFlow.get().getFlowId()));
  }
  Set<Flow> conflictsOnDest;
  if (requestedFlow.getSourceVlan() == 0) {
    conflictsOnDest=flowCache.getFlowsForEndpoint(requestedFlow.getDestinationSwitch(),requestedFlow.getDestinationPort());
  }
 else {
    conflictsOnDest=flowCache.getFlowsForEndpoint(requestedFlow.getDestinationSwitch(),requestedFlow.getDestinationPort(),requestedFlow.getDestinationVlan());
  }
  conflictedFlow=conflictsOnDest.stream().filter(flow -> !flow.getFlowId().equals(requestedFlow.getFlowId())).findAny();
  if (conflictedFlow.isPresent()) {
    throw new FlowValidationException(format("String_Node_Str",requestedFlow.getDestinationPort(),requestedFlow.getDestinationSwitch(),conflictedFlow.get().getFlowId()));
  }
}

Fixed version (ground truth):
/** 
 * Checks a flow for endpoints' conflicts.
 * @param requestedFlow a flow to check
 * @throws FlowValidationException is thrown in a case when flow endpoints conflict with existing flows.
 */
public void checkFlowForEndpointConflicts(Flow requestedFlow) throws FlowValidationException {
  Set<Flow> conflictsOnSource;
  if (requestedFlow.getSourceVlan() == 0) {
    conflictsOnSource=flowCache.getFlowsForEndpoint(requestedFlow.getSourceSwitch(),requestedFlow.getSourcePort());
  }
 else {
    conflictsOnSource=flowCache.getFlowsForEndpoint(requestedFlow.getSourceSwitch(),requestedFlow.getSourcePort(),requestedFlow.getSourceVlan());
  }
  Optional<Flow> conflictedFlow=conflictsOnSource.stream().filter(flow -> !flow.getFlowId().equals(requestedFlow.getFlowId())).findAny();
  if (conflictedFlow.isPresent()) {
    throw new FlowValidationException(format("String_Node_Str",requestedFlow.getSourcePort(),requestedFlow.getSourceSwitch(),conflictedFlow.get().getFlowId()));
  }
  Set<Flow> conflictsOnDest;
  if (requestedFlow.getDestinationVlan() == 0) {
    conflictsOnDest=flowCache.getFlowsForEndpoint(requestedFlow.getDestinationSwitch(),requestedFlow.getDestinationPort());
  }
 else {
    conflictsOnDest=flowCache.getFlowsForEndpoint(requestedFlow.getDestinationSwitch(),requestedFlow.getDestinationPort(),requestedFlow.getDestinationVlan());
  }
  conflictedFlow=conflictsOnDest.stream().filter(flow -> !flow.getFlowId().equals(requestedFlow.getFlowId())).findAny();
  if (conflictedFlow.isPresent()) {
    throw new FlowValidationException(format("String_Node_Str",requestedFlow.getDestinationPort(),requestedFlow.getDestinationSwitch(),conflictedFlow.get().getFlowId()));
  }
}