Program: 171112
Project: 171112
Buggy source:
private void handleExternalTables(final HiveMetaStoreBridge dgiBridge,final HiveEventContext event,final LinkedHashMap<Type,Referenceable> tables) throws HiveException, MalformedURLException {
  List<Referenceable> entities=new ArrayList<>();
  final WriteEntity hiveEntity=(WriteEntity)getEntityByType(event.getOutputs(),Type.TABLE);
  Table hiveTable=hiveEntity.getTable();
  hiveTable=dgiBridge.hiveClient.getTable(hiveTable.getDbName(),hiveTable.getTableName());
  final String location=lower(hiveTable.getDataLocation().toString());
  if (hiveTable != null && TableType.EXTERNAL_TABLE.equals(hiveTable.getTableType())) {
    LOG.info("String_Node_Str",event.getQueryStr());
    final ReadEntity dfsEntity=new ReadEntity();
    dfsEntity.setTyp(Type.DFS_DIR);
    dfsEntity.setName(location);
    SortedMap<ReadEntity,Referenceable> hiveInputsMap=new TreeMap<ReadEntity,Referenceable>(entityComparator){
{
        put(dfsEntity,dgiBridge.fillHDFSDataSet(location));
      }
    }
;
    SortedMap<WriteEntity,Referenceable> hiveOutputsMap=new TreeMap<WriteEntity,Referenceable>(entityComparator){
{
        put(hiveEntity,tables.get(Type.TABLE));
      }
    }
;
    SortedSet<ReadEntity> sortedIps=new TreeSet<>(entityComparator);
    sortedIps.addAll(hiveInputsMap.keySet());
    SortedSet<WriteEntity> sortedOps=new TreeSet<>(entityComparator);
    sortedOps.addAll(hiveOutputsMap.keySet());
    Referenceable processReferenceable=getProcessReferenceable(dgiBridge,event,sortedIps,sortedOps,hiveInputsMap,hiveOutputsMap);
    String tableQualifiedName=dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(),hiveTable);
    if (isCreateOp(event)) {
      LOG.info("String_Node_Str",tableQualifiedName);
      processReferenceable.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,tableQualifiedName);
    }
    entities.addAll(tables.values());
    entities.add(processReferenceable);
    event.addMessage(new HookNotification.EntityUpdateRequest(event.getUser(),entities));
  }
}

Fixed version (ground truth):
private void handleExternalTables(final HiveMetaStoreBridge dgiBridge,final HiveEventContext event,final LinkedHashMap<Type,Referenceable> tables) throws HiveException, MalformedURLException {
  List<Referenceable> entities=new ArrayList<>();
  final WriteEntity hiveEntity=(WriteEntity)getEntityByType(event.getOutputs(),Type.TABLE);
  Table hiveTable=hiveEntity == null ? null : hiveEntity.getTable();
  if (hiveTable != null) {
    hiveTable=dgiBridge.hiveClient.getTable(hiveTable.getDbName(),hiveTable.getTableName());
  }
  if (hiveTable != null && TableType.EXTERNAL_TABLE.equals(hiveTable.getTableType())) {
    LOG.info("String_Node_Str",event.getQueryStr());
    final String location=lower(hiveTable.getDataLocation().toString());
    final ReadEntity dfsEntity=new ReadEntity();
    dfsEntity.setTyp(Type.DFS_DIR);
    dfsEntity.setName(location);
    SortedMap<ReadEntity,Referenceable> hiveInputsMap=new TreeMap<ReadEntity,Referenceable>(entityComparator){
{
        put(dfsEntity,dgiBridge.fillHDFSDataSet(location));
      }
    }
;
    SortedMap<WriteEntity,Referenceable> hiveOutputsMap=new TreeMap<WriteEntity,Referenceable>(entityComparator){
{
        put(hiveEntity,tables.get(Type.TABLE));
      }
    }
;
    SortedSet<ReadEntity> sortedIps=new TreeSet<>(entityComparator);
    sortedIps.addAll(hiveInputsMap.keySet());
    SortedSet<WriteEntity> sortedOps=new TreeSet<>(entityComparator);
    sortedOps.addAll(hiveOutputsMap.keySet());
    Referenceable processReferenceable=getProcessReferenceable(dgiBridge,event,sortedIps,sortedOps,hiveInputsMap,hiveOutputsMap);
    String tableQualifiedName=dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(),hiveTable);
    if (isCreateOp(event)) {
      LOG.info("String_Node_Str",tableQualifiedName);
      processReferenceable.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,tableQualifiedName);
    }
    entities.addAll(tables.values());
    entities.add(processReferenceable);
    event.addMessage(new HookNotification.EntityUpdateRequest(event.getUser(),entities));
  }
}