Program: 171049
Project: 171049
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 == 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.setD(new Path(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);
    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=refreshTable(dgiBridge,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.setD(new Path(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);
    entities.addAll(tables.values());
    entities.add(processReferenceable);
    event.addMessage(new HookNotification.EntityUpdateRequest(event.getUser(),entities));
  }
}