Program: 172357
Project: 172357
Buggy source:
/** 
 * Navigate a Node.
 * @param nodeRef  the node to navigate
 */
private void walkNode(NodeRef nodeRef,ExporterCrawlerParameters parameters,Exporter exporter){
  QName type=nodeService.getType(nodeRef);
  if (isExcludedURI(parameters.getExcludeNamespaceURIs(),type.getNamespaceURI())) {
    return;
  }
  flushCount++;
  if (flushCount > flushThreshold) {
    AlfrescoTransactionSupport.flush();
    flushCount=0;
  }
  exporter.startNode(nodeRef);
  exporter.startAspects(nodeRef);
  Set<QName> aspects=nodeService.getAspects(nodeRef);
  for (  QName aspect : aspects) {
    if (!isExcludedURI(parameters.getExcludeNamespaceURIs(),aspect.getNamespaceURI())) {
      exporter.startAspect(nodeRef,aspect);
      exporter.endAspect(nodeRef,aspect);
    }
  }
  exporter.endAspects(nodeRef);
  Set<AccessPermission> permissions=permissionService.getAllSetPermissions(nodeRef);
  if (permissions.size() > 0) {
    exporter.startACL(nodeRef);
    for (    AccessPermission permission : permissions) {
      exporter.permission(nodeRef,permission);
    }
    exporter.endACL(nodeRef);
  }
  exporter.startProperties(nodeRef);
  Map<QName,Serializable> properties=nodeService.getProperties(nodeRef);
  for (  QName property : properties.keySet()) {
    if (isExcludedURI(parameters.getExcludeNamespaceURIs(),property.getNamespaceURI())) {
      continue;
    }
    Object value=properties.get(property);
    if (!parameters.isCrawlNullProperties() && value == null) {
      continue;
    }
    exporter.startProperty(nodeRef,property);
    PropertyDefinition propertyDef=dictionaryService.getProperty(property);
    boolean isContentProperty=(propertyDef == null) ? false : propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT);
    if (isContentProperty) {
      ContentReader reader=contentService.getReader(nodeRef,property);
      if (reader == null || reader.exists() == false) {
        exporter.warning("String_Node_Str" + property + "String_Node_Str"+ nodeRef);
      }
 else {
        if (parameters.isCrawlContent()) {
          InputStream inputStream=reader.getContentInputStream();
          try {
            exporter.content(nodeRef,property,inputStream,reader.getContentData());
          }
  finally {
            try {
              inputStream.close();
            }
 catch (            IOException e) {
              throw new ExporterException("String_Node_Str" + nodeRef,e);
            }
          }
        }
 else {
          exporter.content(nodeRef,property,null,null);
        }
      }
    }
 else {
      try {
        if (value instanceof Collection) {
          exporter.value(nodeRef,property,(Collection)value);
        }
 else {
          exporter.value(nodeRef,property,value);
        }
      }
 catch (      TypeConversionException e) {
        exporter.warning("String_Node_Str" + property + "String_Node_Str");
        exporter.value(nodeRef,property,properties.get(property).toString());
      }
    }
    exporter.endProperty(nodeRef,property);
  }
  exporter.endProperties(nodeRef);
  if (parameters.isCrawlChildNodes()) {
    exporter.startAssocs(nodeRef);
    List<ChildAssociationRef> childAssocs=nodeService.getChildAssocs(nodeRef);
    for (int i=0; i < childAssocs.size(); i++) {
      ChildAssociationRef childAssoc=childAssocs.get(i);
      QName childAssocType=childAssoc.getTypeQName();
      if (isExcludedURI(parameters.getExcludeNamespaceURIs(),childAssocType.getNamespaceURI())) {
        continue;
      }
      if (i == 0 || childAssocs.get(i - 1).getTypeQName().equals(childAssocType) == false) {
        exporter.startAssoc(nodeRef,childAssocType);
      }
      if (!isExcludedURI(parameters.getExcludeNamespaceURIs(),childAssoc.getQName().getNamespaceURI())) {
        walkNode(childAssoc.getChildRef(),parameters,exporter);
      }
      if (i == childAssocs.size() - 1 || childAssocs.get(i + 1).getTypeQName().equals(childAssocType) == false) {
        exporter.endAssoc(nodeRef,childAssocType);
      }
    }
    exporter.endAssocs(nodeRef);
  }
  exporter.endNode(nodeRef);
}

Fixed version (ground truth):
/** 
 * Navigate a Node.
 * @param nodeRef  the node to navigate
 */
private void walkNode(NodeRef nodeRef,ExporterCrawlerParameters parameters,Exporter exporter){
  QName type=nodeService.getType(nodeRef);
  if (isExcludedURI(parameters.getExcludeNamespaceURIs(),type.getNamespaceURI())) {
    return;
  }
  flushCount++;
  if (flushCount > flushThreshold) {
    AlfrescoTransactionSupport.flush();
    flushCount=0;
  }
  exporter.startNode(nodeRef);
  exporter.startAspects(nodeRef);
  Set<QName> aspects=nodeService.getAspects(nodeRef);
  for (  QName aspect : aspects) {
    if (!isExcludedURI(parameters.getExcludeNamespaceURIs(),aspect.getNamespaceURI())) {
      exporter.startAspect(nodeRef,aspect);
      exporter.endAspect(nodeRef,aspect);
    }
  }
  exporter.endAspects(nodeRef);
  Set<AccessPermission> permissions=permissionService.getAllSetPermissions(nodeRef);
  boolean inheritPermissions=permissionService.getInheritParentPermissions(nodeRef);
  if (permissions.size() > 0 || !inheritPermissions) {
    exporter.startACL(nodeRef);
    for (    AccessPermission permission : permissions) {
      exporter.permission(nodeRef,permission);
    }
    exporter.endACL(nodeRef);
  }
  exporter.startProperties(nodeRef);
  Map<QName,Serializable> properties=nodeService.getProperties(nodeRef);
  for (  QName property : properties.keySet()) {
    if (isExcludedURI(parameters.getExcludeNamespaceURIs(),property.getNamespaceURI())) {
      continue;
    }
    Object value=properties.get(property);
    if (!parameters.isCrawlNullProperties() && value == null) {
      continue;
    }
    exporter.startProperty(nodeRef,property);
    PropertyDefinition propertyDef=dictionaryService.getProperty(property);
    boolean isContentProperty=(propertyDef == null) ? false : propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT);
    if (isContentProperty) {
      ContentReader reader=contentService.getReader(nodeRef,property);
      if (reader == null || reader.exists() == false) {
        exporter.warning("String_Node_Str" + property + "String_Node_Str"+ nodeRef);
      }
 else {
        if (parameters.isCrawlContent()) {
          InputStream inputStream=reader.getContentInputStream();
          try {
            exporter.content(nodeRef,property,inputStream,reader.getContentData());
          }
  finally {
            try {
              inputStream.close();
            }
 catch (            IOException e) {
              throw new ExporterException("String_Node_Str" + nodeRef,e);
            }
          }
        }
 else {
          exporter.content(nodeRef,property,null,null);
        }
      }
    }
 else {
      try {
        if (value instanceof Collection) {
          exporter.value(nodeRef,property,(Collection)value);
        }
 else {
          exporter.value(nodeRef,property,value);
        }
      }
 catch (      TypeConversionException e) {
        exporter.warning("String_Node_Str" + property + "String_Node_Str");
        exporter.value(nodeRef,property,properties.get(property).toString());
      }
    }
    exporter.endProperty(nodeRef,property);
  }
  exporter.endProperties(nodeRef);
  if (parameters.isCrawlChildNodes()) {
    exporter.startAssocs(nodeRef);
    List<ChildAssociationRef> childAssocs=nodeService.getChildAssocs(nodeRef);
    for (int i=0; i < childAssocs.size(); i++) {
      ChildAssociationRef childAssoc=childAssocs.get(i);
      QName childAssocType=childAssoc.getTypeQName();
      if (isExcludedURI(parameters.getExcludeNamespaceURIs(),childAssocType.getNamespaceURI())) {
        continue;
      }
      if (i == 0 || childAssocs.get(i - 1).getTypeQName().equals(childAssocType) == false) {
        exporter.startAssoc(nodeRef,childAssocType);
      }
      if (!isExcludedURI(parameters.getExcludeNamespaceURIs(),childAssoc.getQName().getNamespaceURI())) {
        walkNode(childAssoc.getChildRef(),parameters,exporter);
      }
      if (i == childAssocs.size() - 1 || childAssocs.get(i + 1).getTypeQName().equals(childAssocType) == false) {
        exporter.endAssoc(nodeRef,childAssocType);
      }
    }
    exporter.endAssocs(nodeRef);
  }
  exporter.endNode(nodeRef);
}