Program: 135848
Project: 135848
Buggy source:
/** 
 * Add addresses into the MD-SAL data tree
 * @param macAddress  The MacAddress of the new L2Address object
 * @param nodeConnectorRef  The NodeConnectorRef of the new L2Address object
 */
public void addAddress(MacAddress macAddress,IpAddress ipAddress,NodeConnectorRef nodeConnectorRef){
  if (macAddress == null || ipAddress == null || nodeConnectorRef == null) {
    return;
  }
  long now=new Date().getTime();
  final AddressCapableNodeConnectorBuilder acncBuilder=new AddressCapableNodeConnectorBuilder();
  final AddressesBuilder addressBuilder=new AddressesBuilder().setIp(ipAddress).setMac(macAddress).setFirstSeen(now).setLastSeen(now).setKey(new AddressesKey(now));
  List<Addresses> addresses=null;
  NodeConnector nc=(NodeConnector)dataService.readOperationalData(nodeConnectorRef.getValue());
  AddressCapableNodeConnector acnc=(AddressCapableNodeConnector)nc.getAugmentation(AddressCapableNodeConnector.class);
  if (acnc != null && acnc.getAddresses() != null) {
    addresses=acnc.getAddresses();
    for (int i=0; i < addresses.size(); i++) {
      if (addresses.get(i).getIp().equals(ipAddress) && addresses.get(i).getMac().equals(macAddress)) {
        addressBuilder.setFirstSeen(addresses.get(i).getFirstSeen()).setKey(addresses.get(i).getKey());
        addresses.remove(i);
        break;
      }
    }
  }
 else {
    addresses=new ArrayList<>();
  }
  addresses.add(addressBuilder.build());
  acncBuilder.setAddresses(addresses);
  NodeConnectorBuilder ncBuilder=new NodeConnectorBuilder(nc).setKey(nc.getKey()).addAugmentation(AddressCapableNodeConnector.class,acncBuilder.build());
  final DataModificationTransaction it=dataService.beginTransaction();
  it.putOperationalData(nodeConnectorRef.getValue(),ncBuilder.build());
  it.commit();
}

Fixed version (ground truth):
/** 
 * Add addresses into the MD-SAL data tree
 * @param macAddress       The MacAddress of the new L2Address object
 * @param nodeConnectorRef The NodeConnectorRef of the new L2Address object
 */
public void addAddress(MacAddress macAddress,IpAddress ipAddress,NodeConnectorRef nodeConnectorRef){
  if (macAddress == null || ipAddress == null || nodeConnectorRef == null) {
    return;
  }
  NodeConnectorLock nodeConnectorLock;
synchronized (this) {
    nodeConnectorLock=lockMap.get(nodeConnectorRef);
    if (nodeConnectorLock == null) {
      nodeConnectorLock=new NodeConnectorLock();
      lockMap.put(nodeConnectorRef,nodeConnectorLock);
    }
  }
synchronized (nodeConnectorLock) {
    long now=new Date().getTime();
    final AddressCapableNodeConnectorBuilder acncBuilder=new AddressCapableNodeConnectorBuilder();
    final AddressesBuilder addressBuilder=new AddressesBuilder().setIp(ipAddress).setMac(macAddress).setFirstSeen(now).setLastSeen(now).setKey(new AddressesKey(now));
    List<Addresses> addresses=null;
    ReadWriteTransaction readWriteTransaction=dataService.newReadWriteTransaction();
    NodeConnector nc=null;
    try {
      Optional<DataObject> dataObjectOptional=readWriteTransaction.read(LogicalDatastoreType.OPERATIONAL,nodeConnectorRef.getValue()).get();
      if (dataObjectOptional.isPresent())       nc=(NodeConnector)dataObjectOptional.get();
    }
 catch (    Exception e) {
      _logger.error("String_Node_Str",nodeConnectorRef.getValue());
      readWriteTransaction.commit();
      throw new RuntimeException("String_Node_Str" + nodeConnectorRef,e);
    }
    if (nc == null) {
      readWriteTransaction.commit();
      return;
    }
    AddressCapableNodeConnector acnc=(AddressCapableNodeConnector)nc.getAugmentation(AddressCapableNodeConnector.class);
    if (acnc != null && acnc.getAddresses() != null) {
      addresses=acnc.getAddresses();
      for (int i=0; i < addresses.size(); i++) {
        if (addresses.get(i).getIp().equals(ipAddress) && addresses.get(i).getMac().equals(macAddress)) {
          addressBuilder.setFirstSeen(addresses.get(i).getFirstSeen()).setKey(addresses.get(i).getKey());
          addresses.remove(i);
          break;
        }
      }
    }
 else {
      addresses=new ArrayList<>();
    }
    addresses.add(addressBuilder.build());
    acncBuilder.setAddresses(addresses);
    NodeConnectorBuilder ncBuilder=new NodeConnectorBuilder(nc).setKey(nc.getKey()).addAugmentation(AddressCapableNodeConnector.class,acncBuilder.build());
    readWriteTransaction.put(LogicalDatastoreType.OPERATIONAL,nodeConnectorRef.getValue(),ncBuilder.build());
    readWriteTransaction.commit();
  }
}