Program: 161262
Project: 161262
Buggy source:
private void acquireAndUpdateGrsData(final GrsSource grsSource,final boolean rebuild,final ResourceData resourceData){
  final Logger logger=grsSource.getLogger();
  new Runnable(){
    private int nrCreated;
    private int nrUpdated;
    private int nrDeleted;
    private int nrIgnored;
    private int nrHandled;
    private Set<Integer> currentObjectIds;
    private Set<Integer> incompletelyIndexedObjectIds=Sets.newHashSet();
    @Override public void run(){
      final File dumpFile=new File(downloadDir,String.format("String_Node_Str",grsSource.getSource()));
      grsDownloader.acquire(grsSource,dumpFile,new GrsDownloader.AcquireHandler(){
        @Override public void acquire(        final File file) throws IOException {
          grsSource.acquireDump(file);
        }
      }
);
      final Stopwatch stopwatch=new Stopwatch().start();
      if (rebuild) {
        grsSource.getDao().cleanDatabase();
        currentObjectIds=Collections.emptySet();
        logger.info("String_Node_Str");
      }
 else {
        currentObjectIds=Sets.newHashSet(grsSource.getDao().getCurrentObjectIds());
        logger.info("String_Node_Str",currentObjectIds.size());
      }
      try {
        importObjects(dumpFile);
        deleteNotFoundInImport();
      }
 catch (      IOException e) {
        throw new RuntimeException(e);
      }
 finally {
        logger.info("String_Node_Str",nrCreated,nrUpdated,nrDeleted,nrIgnored,stopwatch.stop());
      }
      updateIndexes();
    }
    private void importObjects(    final File dumpFile) throws IOException {
      grsSource.handleObjects(dumpFile,new ObjectHandler(){
        @Override public void handle(        final List<String> lines){
          final String rpslObjectString=LINE_JOINER.join(lines);
          final RpslObjectBase rpslObject;
          try {
            rpslObject=RpslObjectBase.parse(rpslObjectString);
          }
 catch (          RuntimeException e) {
            logger.warn("String_Node_Str",rpslObjectString);
            return;
          }
          handle(rpslObject);
        }
        @Override public void handle(        final RpslObjectBase rpslObjectBase){
          if (rpslObjectBase.getType() == null) {
            logger.debug("String_Node_Str",rpslObjectBase);
            nrIgnored++;
          }
 else {
            final ObjectMessages messages=new ObjectMessages();
            final RpslObject filteredObject=new RpslObject(filterObject(rpslObjectBase));
            final RpslObject rpslObject=sanitizer.sanitize(filteredObject,messages);
            final RpslAttribute typeAttribute=rpslObject.getTypeAttribute();
            typeAttribute.validateSyntax(rpslObject.getType(),messages);
            if (messages.hasErrors()) {
              logger.debug("String_Node_Str",typeAttribute,messages);
              nrIgnored++;
            }
 else             if (resourceData.isMaintainedInRirSpace(rpslObject)) {
              createOrUpdate(rpslObject);
            }
          }
          nrHandled++;
          if (nrHandled % LOG_EVERY_NR_HANDLED == 0) {
            logger.debug("String_Node_Str",nrHandled);
          }
        }
        private RpslObjectBase filterObject(        final RpslObjectBase rpslObject){
          final RpslAttribute sourceAttribute=new RpslAttribute(AttributeType.SOURCE,grsSource.getSource());
          final ObjectTemplate objectTemplate=ObjectTemplate.getTemplate(rpslObject.getType());
          final Set<AttributeType> attributeTypes=objectTemplate.getAllAttributes();
          final List<RpslAttribute> attributes=rpslObject.getAttributes();
          final List<RpslAttribute> newAttributes=Lists.newArrayListWithExpectedSize(attributes.size());
          final Set<AttributeType> newAttributeTypes=Sets.newHashSet();
          for (          final RpslAttribute attribute : attributes) {
            final AttributeType attributeType=attribute.getType();
            if (attributeType == null || !attributeTypes.contains(attributeType)) {
              logger.debug("String_Node_Str",rpslObject.getFormattedKey(),attribute);
              continue;
            }
            newAttributeTypes.add(attributeType);
            if (attributeType.equals(AttributeType.SOURCE)) {
              newAttributes.add(sourceAttribute);
            }
 else {
              newAttributes.add(attribute);
            }
          }
          if (!newAttributeTypes.contains(AttributeType.SOURCE)) {
            newAttributes.add(sourceAttribute);
          }
          return new RpslObjectBase(newAttributes);
        }
        private void createOrUpdate(        final RpslObject importedObject){
          final GrsObjectInfo grsObjectInfo=grsSource.getDao().find(importedObject.getKey().toString(),importedObject.getType());
          if (grsObjectInfo == null) {
            create(importedObject);
          }
 else {
            currentObjectIds.remove(grsObjectInfo.getObjectId());
            if (!grsObjectInfo.getRpslObject().equals(importedObject)) {
              update(importedObject,grsObjectInfo);
            }
          }
        }
        private void create(        final RpslObject importedObject){
          final GrsDao.UpdateResult updateResult=grsSource.getDao().createObject(importedObject);
          if (updateResult.hasMissingReferences()) {
            incompletelyIndexedObjectIds.add(updateResult.getObjectId());
          }
          nrCreated++;
        }
        private void update(        final RpslObject importedObject,        final GrsObjectInfo grsObjectInfo){
          final GrsDao.UpdateResult updateResult=grsSource.getDao().updateObject(grsObjectInfo,importedObject);
          if (updateResult.hasMissingReferences()) {
            incompletelyIndexedObjectIds.add(updateResult.getObjectId());
          }
          nrUpdated++;
        }
      }
);
    }
    private void deleteNotFoundInImport(){
      if (nrCreated == 0 && nrUpdated == 0) {
        logger.warn("String_Node_Str");
        return;
      }
      logger.info("String_Node_Str",currentObjectIds.size());
      for (      final Integer objectId : currentObjectIds) {
        try {
          grsSource.getDao().deleteObject(objectId);
          nrDeleted++;
        }
 catch (        RuntimeException e) {
          logger.error("String_Node_Str",objectId,e);
        }
      }
    }
    private void updateIndexes(){
      logger.info("String_Node_Str",incompletelyIndexedObjectIds.size());
      int nrUpdated=0;
      for (      final Integer objectId : incompletelyIndexedObjectIds) {
        try {
          grsSource.getDao().updateIndexes(objectId);
        }
 catch (        RuntimeException e) {
          logger.error("String_Node_Str",objectId,e);
        }
        nrUpdated++;
        if (nrUpdated % LOG_EVERY_NR_HANDLED == 0) {
          logger.info("String_Node_Str",nrUpdated);
        }
      }
    }
  }
.run();
}

Fixed version (ground truth):
private void acquireAndUpdateGrsData(final GrsSource grsSource,final boolean rebuild,final ResourceData resourceData){
  final Logger logger=grsSource.getLogger();
  new Runnable(){
    private int nrCreated;
    private int nrUpdated;
    private int nrDeleted;
    private int nrIgnored;
    private int nrHandled;
    private Set<Integer> currentObjectIds;
    private Set<Integer> incompletelyIndexedObjectIds=Sets.newHashSet();
    @Override public void run(){
      final File dumpFile=new File(downloadDir,String.format("String_Node_Str",grsSource.getSource()));
      grsDownloader.acquire(grsSource,dumpFile,new GrsDownloader.AcquireHandler(){
        @Override public void acquire(        final File file) throws IOException {
          grsSource.acquireDump(file);
        }
      }
);
      final Stopwatch stopwatch=new Stopwatch().start();
      if (rebuild) {
        grsSource.getDao().cleanDatabase();
        currentObjectIds=Collections.emptySet();
        logger.info("String_Node_Str");
      }
 else {
        currentObjectIds=Sets.newHashSet(grsSource.getDao().getCurrentObjectIds());
        logger.info("String_Node_Str",currentObjectIds.size());
      }
      try {
        importObjects(dumpFile);
        deleteNotFoundInImport();
      }
 catch (      IOException e) {
        throw new RuntimeException(e);
      }
 finally {
        logger.info("String_Node_Str",nrCreated,nrUpdated,nrDeleted,nrIgnored,stopwatch.stop());
      }
      updateIndexes();
    }
    private void importObjects(    final File dumpFile) throws IOException {
      grsSource.handleObjects(dumpFile,new ObjectHandler(){
        @Override public void handle(        final List<String> lines){
          final String rpslObjectString=LINE_JOINER.join(lines);
          final RpslObjectBase rpslObject;
          try {
            rpslObject=RpslObjectBase.parse(rpslObjectString);
          }
 catch (          RuntimeException e) {
            logger.warn("String_Node_Str",rpslObjectString);
            return;
          }
          handle(rpslObject);
        }
        @Override public void handle(        final RpslObjectBase rpslObjectBase){
          if (rpslObjectBase.getType() == null) {
            logger.debug("String_Node_Str",rpslObjectBase);
            nrIgnored++;
          }
 else {
            final ObjectMessages messages=new ObjectMessages();
            final RpslObject filteredObject=new RpslObject(filterObject(rpslObjectBase));
            final RpslObject rpslObject=sanitizer.sanitize(filteredObject,messages);
            final RpslAttribute typeAttribute=rpslObject.getTypeAttribute();
            typeAttribute.validateSyntax(rpslObject.getType(),messages);
            if (messages.hasErrors()) {
              logger.debug("String_Node_Str",typeAttribute,messages);
              nrIgnored++;
            }
 else             if (resourceData.isMaintainedInRirSpace(rpslObject)) {
              createOrUpdate(rpslObject);
            }
          }
          nrHandled++;
          if (nrHandled % LOG_EVERY_NR_HANDLED == 0) {
            logger.debug("String_Node_Str",nrHandled);
          }
        }
        private RpslObjectBase filterObject(        final RpslObjectBase rpslObject){
          final RpslAttribute sourceAttribute=new RpslAttribute(AttributeType.SOURCE,grsSource.getSource());
          final ObjectTemplate objectTemplate=ObjectTemplate.getTemplate(rpslObject.getType());
          final Set<AttributeType> attributeTypes=objectTemplate.getAllAttributes();
          final List<RpslAttribute> attributes=rpslObject.getAttributes();
          final List<RpslAttribute> newAttributes=Lists.newArrayListWithExpectedSize(attributes.size());
          final Set<AttributeType> newAttributeTypes=Sets.newHashSet();
          for (          final RpslAttribute attribute : attributes) {
            final AttributeType attributeType=attribute.getType();
            if (attributeType == null || !attributeTypes.contains(attributeType)) {
              logger.debug("String_Node_Str",rpslObject.getFormattedKey(),attribute);
              continue;
            }
            newAttributeTypes.add(attributeType);
            if (attributeType.equals(AttributeType.SOURCE)) {
              newAttributes.add(sourceAttribute);
            }
 else {
              newAttributes.add(attribute);
            }
          }
          if (!newAttributeTypes.contains(AttributeType.SOURCE)) {
            newAttributes.add(sourceAttribute);
          }
          return new RpslObjectBase(newAttributes);
        }
        private void createOrUpdate(        final RpslObject importedObject){
          final String pkey=importedObject.getKey().toString();
          final ObjectType type=importedObject.getType();
          final GrsObjectInfo grsObjectInfo=grsSource.getDao().find(pkey,type);
          if (grsObjectInfo == null) {
            if (type == ObjectType.PERSON && grsSource.getDao().find(pkey,ObjectType.ROLE) != null) {
              return;
            }
            if (type == ObjectType.ROLE && grsSource.getDao().find(pkey,ObjectType.PERSON) != null) {
              return;
            }
            create(importedObject);
          }
 else {
            currentObjectIds.remove(grsObjectInfo.getObjectId());
            if (!grsObjectInfo.getRpslObject().equals(importedObject)) {
              update(importedObject,grsObjectInfo);
            }
          }
        }
        private void create(        final RpslObject importedObject){
          final GrsDao.UpdateResult updateResult=grsSource.getDao().createObject(importedObject);
          if (updateResult.hasMissingReferences()) {
            incompletelyIndexedObjectIds.add(updateResult.getObjectId());
          }
          nrCreated++;
        }
        private void update(        final RpslObject importedObject,        final GrsObjectInfo grsObjectInfo){
          final GrsDao.UpdateResult updateResult=grsSource.getDao().updateObject(grsObjectInfo,importedObject);
          if (updateResult.hasMissingReferences()) {
            incompletelyIndexedObjectIds.add(updateResult.getObjectId());
          }
          nrUpdated++;
        }
      }
);
    }
    private void deleteNotFoundInImport(){
      if (nrCreated == 0 && nrUpdated == 0) {
        logger.warn("String_Node_Str");
        return;
      }
      logger.info("String_Node_Str",currentObjectIds.size());
      for (      final Integer objectId : currentObjectIds) {
        try {
          grsSource.getDao().deleteObject(objectId);
          nrDeleted++;
        }
 catch (        RuntimeException e) {
          logger.error("String_Node_Str",objectId,e);
        }
      }
    }
    private void updateIndexes(){
      logger.info("String_Node_Str",incompletelyIndexedObjectIds.size());
      int nrUpdated=0;
      for (      final Integer objectId : incompletelyIndexedObjectIds) {
        try {
          grsSource.getDao().updateIndexes(objectId);
        }
 catch (        RuntimeException e) {
          logger.error("String_Node_Str",objectId,e);
        }
        nrUpdated++;
        if (nrUpdated % LOG_EVERY_NR_HANDLED == 0) {
          logger.info("String_Node_Str",nrUpdated);
        }
      }
    }
  }
.run();
}