Program: 63632
Project: 63632
Buggy source:
private void parsePair(String name,JsonValue jsonValue) throws SAXException {
  if (jsonValue == null) {
    return;
  }
  ValueType valueType=jsonValue.getValueType();
  if (valueType == ValueType.ARRAY) {
    JsonArray jsonArray=(JsonArray)jsonValue;
    String parentLocalName=name;
    if (attributePrefix != null && parentLocalName.startsWith(attributePrefix)) {
      return;
    }
    String uri=Constants.EMPTY_STRING;
    if (namespaceAware && namespaces != null) {
      if (parentLocalName.length() > 2) {
        int nsIndex=parentLocalName.indexOf(namespaceSeparator,1);
        if (nsIndex > -1) {
          String prefix=parentLocalName.substring(0,nsIndex);
          uri=namespaces.resolveNamespacePrefix(prefix);
        }
        if (uri == null) {
          uri=namespaces.getDefaultNamespaceURI();
        }
 else {
          parentLocalName=parentLocalName.substring(nsIndex + 1);
        }
      }
 else {
        uri=namespaces.getDefaultNamespaceURI();
      }
    }
    boolean isTextValue=isTextValue(parentLocalName);
    int arraySize=jsonArray.size();
    if (arraySize == 0) {
      if (contentHandler instanceof UnmarshalRecord) {
        UnmarshalRecord ur=(UnmarshalRecord)contentHandler;
        XPathNode node=ur.getNonAttributeXPathNode(uri,parentLocalName,parentLocalName,null);
        if (node != null) {
          NodeValue nv=node.getNodeValue();
          if (nv == null && node.getTextNode() != null) {
            nv=node.getTextNode().getUnmarshalNodeValue();
          }
          if (nv != null && nv.isContainerValue()) {
            ur.getContainerInstance(((ContainerValue)nv));
          }
        }
      }
    }
    startCollection();
    XPathFragment groupingXPathFragment=null;
    XPathFragment itemXPathFragment=null;
    if (contentHandler instanceof UnmarshalRecord) {
      UnmarshalRecord unmarshalRecord=(UnmarshalRecord)contentHandler;
      if (unmarshalRecord.getUnmarshaller().isWrapperAsCollectionName()) {
        XPathNode unmarshalRecordXPathNode=unmarshalRecord.getXPathNode();
        if (null != unmarshalRecordXPathNode) {
          XPathFragment currentFragment=new XPathFragment();
          currentFragment.setLocalName(parentLocalName);
          currentFragment.setNamespaceURI(uri);
          currentFragment.setNamespaceAware(namespaceAware);
          XPathNode groupingXPathNode=unmarshalRecordXPathNode.getNonAttributeChildrenMap().get(currentFragment);
          if (groupingXPathNode != null) {
            if (groupingXPathNode.getUnmarshalNodeValue() instanceof CollectionGroupingElementNodeValue) {
              groupingXPathFragment=groupingXPathNode.getXPathFragment();
              contentHandler.startElement(uri,parentLocalName,parentLocalName,new AttributesImpl());
              XPathNode itemXPathNode=groupingXPathNode.getNonAttributeChildren().get(0);
              itemXPathFragment=itemXPathNode.getXPathFragment();
            }
 else             if (groupingXPathNode.getUnmarshalNodeValue() == null) {
              XPathNode itemXPathNode=groupingXPathNode.getNonAttributeChildren().get(0);
              if (itemXPathNode != null) {
                if (((MappingNodeValue)itemXPathNode.getUnmarshalNodeValue()).isContainerValue()) {
                  groupingXPathFragment=groupingXPathNode.getXPathFragment();
                  contentHandler.startElement(uri,parentLocalName,parentLocalName,new AttributesImpl());
                  itemXPathFragment=itemXPathNode.getXPathFragment();
                }
              }
            }
          }
        }
      }
      for (int i=0; i < arraySize; i++) {
        JsonValue nextArrayValue=jsonArray.get(i);
        if (nextArrayValue.getValueType() == ValueType.NULL) {
          ((UnmarshalRecord)contentHandler).setNil(true);
        }
        if (!isTextValue) {
          if (null != itemXPathFragment) {
            contentHandler.startElement(itemXPathFragment.getNamespaceURI(),itemXPathFragment.getLocalName(),itemXPathFragment.getLocalName(),attributes.setValue(nextArrayValue,attributePrefix,namespaces,namespaceSeparator,namespaceAware));
          }
 else {
            contentHandler.startElement(uri,parentLocalName,parentLocalName,attributes.setValue(nextArrayValue,attributePrefix,namespaces,namespaceSeparator,namespaceAware));
          }
        }
        parseValue(nextArrayValue);
        if (!isTextValue) {
          if (null != itemXPathFragment) {
            contentHandler.endElement(itemXPathFragment.getNamespaceURI(),itemXPathFragment.getLocalName(),itemXPathFragment.getLocalName());
          }
 else {
            contentHandler.endElement(uri,parentLocalName,parentLocalName);
          }
        }
      }
    }
    if (null != groupingXPathFragment) {
      contentHandler.endElement(uri,groupingXPathFragment.getLocalName(),groupingXPathFragment.getLocalName());
    }
    endCollection();
  }
 else {
    String qualifiedName=name;
    if (attributePrefix != null && qualifiedName.startsWith(attributePrefix)) {
      return;
    }
    String localName=qualifiedName;
    String uri=Constants.EMPTY_STRING;
    if (namespaceAware && namespaces != null) {
      if (localName.length() > 2) {
        int nsIndex=localName.indexOf(namespaceSeparator,1);
        String prefix=Constants.EMPTY_STRING;
        if (nsIndex > -1) {
          prefix=localName.substring(0,nsIndex);
        }
        uri=namespaces.resolveNamespacePrefix(prefix);
        if (uri == null) {
          uri=namespaces.getDefaultNamespaceURI();
        }
 else {
          localName=localName.substring(nsIndex + 1);
        }
        if (localName.equals(Constants.SCHEMA_TYPE_ATTRIBUTE) && uri != null && uri.equals(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI)) {
          return;
        }
      }
 else {
        uri=namespaces.getDefaultNamespaceURI();
      }
    }
    if (contentHandler instanceof XMLRootRecord || contentHandler instanceof DeferredContentHandler) {
      if (!namespaceAware && localName.equals(Constants.SCHEMA_TYPE_ATTRIBUTE)) {
        return;
      }
      if (textWrapper != null && textWrapper.equals(localName)) {
        parseValue(jsonValue);
        return;
      }
    }
 else     if (contentHandler instanceof UnmarshalRecord && ((UnmarshalRecord)contentHandler).getXPathNode() != null) {
      if (!namespaceAware && localName.equals(Constants.SCHEMA_TYPE_ATTRIBUTE) && !((UnmarshalRecord)contentHandler).getXPathNode().hasTypeChild()) {
        return;
      }
      boolean isTextValue=isTextValue(localName);
      if (isTextValue) {
        parseValue(jsonValue);
        return;
      }
    }
    if (jsonValue != null && jsonValue.getValueType() == valueType.NULL) {
      contentHandler.setNil(true);
    }
    contentHandler.startElement(uri,localName,localName,attributes.setValue(jsonValue,attributePrefix,namespaces,namespaceSeparator,namespaceAware));
    parseValue(jsonValue);
    contentHandler.endElement(uri,localName,localName);
  }
}

Fixed version (ground truth):
private void parsePair(String name,JsonValue jsonValue) throws SAXException {
  if (jsonValue == null) {
    return;
  }
  ValueType valueType=jsonValue.getValueType();
  if (valueType == ValueType.ARRAY) {
    JsonArray jsonArray=(JsonArray)jsonValue;
    String parentLocalName=name;
    if (attributePrefix != null && parentLocalName.startsWith(attributePrefix)) {
      return;
    }
    String uri=Constants.EMPTY_STRING;
    if (namespaceAware && namespaces != null) {
      if (parentLocalName.length() > 2) {
        int nsIndex=parentLocalName.indexOf(namespaceSeparator,1);
        if (nsIndex > -1) {
          String prefix=parentLocalName.substring(0,nsIndex);
          uri=namespaces.resolveNamespacePrefix(prefix);
        }
        if (uri == null) {
          uri=namespaces.getDefaultNamespaceURI();
        }
 else {
          parentLocalName=parentLocalName.substring(nsIndex + 1);
        }
      }
 else {
        uri=namespaces.getDefaultNamespaceURI();
      }
    }
    boolean isTextValue=isTextValue(parentLocalName);
    int arraySize=jsonArray.size();
    if (arraySize == 0) {
      if (contentHandler instanceof UnmarshalRecord) {
        UnmarshalRecord ur=(UnmarshalRecord)contentHandler;
        XPathNode node=ur.getNonAttributeXPathNode(uri,parentLocalName,parentLocalName,null);
        if (node != null) {
          NodeValue nv=node.getNodeValue();
          if (nv == null && node.getTextNode() != null) {
            nv=node.getTextNode().getUnmarshalNodeValue();
          }
          if (nv != null && nv.isContainerValue()) {
            ur.getContainerInstance(((ContainerValue)nv));
          }
        }
      }
    }
    startCollection();
    XPathFragment groupingXPathFragment=null;
    XPathFragment itemXPathFragment=null;
    if (contentHandler instanceof UnmarshalRecord) {
      UnmarshalRecord unmarshalRecord=(UnmarshalRecord)contentHandler;
      if (unmarshalRecord.getUnmarshaller().isWrapperAsCollectionName()) {
        XPathNode unmarshalRecordXPathNode=unmarshalRecord.getXPathNode();
        if (null != unmarshalRecordXPathNode) {
          XPathFragment currentFragment=new XPathFragment();
          currentFragment.setLocalName(parentLocalName);
          currentFragment.setNamespaceURI(uri);
          currentFragment.setNamespaceAware(namespaceAware);
          XPathNode groupingXPathNode=unmarshalRecordXPathNode.getNonAttributeChildrenMap().get(currentFragment);
          if (groupingXPathNode != null) {
            if (groupingXPathNode.getUnmarshalNodeValue() instanceof CollectionGroupingElementNodeValue) {
              groupingXPathFragment=groupingXPathNode.getXPathFragment();
              contentHandler.startElement(uri,parentLocalName,parentLocalName,new AttributesImpl());
              XPathNode itemXPathNode=groupingXPathNode.getNonAttributeChildren().get(0);
              itemXPathFragment=itemXPathNode.getXPathFragment();
            }
 else             if (groupingXPathNode.getUnmarshalNodeValue() == null) {
              XPathNode itemXPathNode=groupingXPathNode.getNonAttributeChildren().get(0);
              if (itemXPathNode != null) {
                if (((MappingNodeValue)itemXPathNode.getUnmarshalNodeValue()).isContainerValue()) {
                  groupingXPathFragment=groupingXPathNode.getXPathFragment();
                  contentHandler.startElement(uri,parentLocalName,parentLocalName,new AttributesImpl());
                  itemXPathFragment=itemXPathNode.getXPathFragment();
                }
              }
            }
          }
        }
      }
      for (int i=0; i < arraySize; i++) {
        JsonValue nextArrayValue=jsonArray.get(i);
        if (nextArrayValue.getValueType() == ValueType.NULL) {
          ((UnmarshalRecord)contentHandler).setNil(true);
        }
        if (!isTextValue) {
          if (null != itemXPathFragment) {
            contentHandler.startElement(itemXPathFragment.getNamespaceURI(),itemXPathFragment.getLocalName(),itemXPathFragment.getLocalName(),attributes.setValue(nextArrayValue,attributePrefix,namespaces,namespaceSeparator,namespaceAware));
          }
 else {
            contentHandler.startElement(uri,parentLocalName,parentLocalName,attributes.setValue(nextArrayValue,attributePrefix,namespaces,namespaceSeparator,namespaceAware));
          }
        }
        parseValue(nextArrayValue);
        if (!isTextValue) {
          if (null != itemXPathFragment) {
            contentHandler.endElement(itemXPathFragment.getNamespaceURI(),itemXPathFragment.getLocalName(),itemXPathFragment.getLocalName());
          }
 else {
            contentHandler.endElement(uri,parentLocalName,parentLocalName);
          }
        }
      }
    }
    if (null != groupingXPathFragment) {
      contentHandler.endElement(uri,groupingXPathFragment.getLocalName(),groupingXPathFragment.getLocalName());
    }
    endCollection();
  }
 else {
    String qualifiedName=name;
    if (attributePrefix != null && qualifiedName.startsWith(attributePrefix)) {
      return;
    }
    String localName=qualifiedName;
    String uri=Constants.EMPTY_STRING;
    if (namespaceAware && namespaces != null) {
      if (localName.length() > 2) {
        int nsIndex=localName.indexOf(namespaceSeparator,1);
        String prefix=Constants.EMPTY_STRING;
        if (nsIndex > -1) {
          prefix=localName.substring(0,nsIndex);
        }
        uri=namespaces.resolveNamespacePrefix(prefix);
        if (uri == null) {
          uri=namespaces.getDefaultNamespaceURI();
        }
 else {
          localName=localName.substring(nsIndex + 1);
        }
        if (localName.equals(Constants.SCHEMA_TYPE_ATTRIBUTE) && uri != null && uri.equals(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI)) {
          return;
        }
      }
 else {
        uri=namespaces.getDefaultNamespaceURI();
      }
    }
    if (contentHandler instanceof XMLRootRecord || contentHandler instanceof DeferredContentHandler) {
      if (!namespaceAware && localName.equals(Constants.SCHEMA_TYPE_ATTRIBUTE)) {
        return;
      }
      if (textWrapper != null && textWrapper.equals(localName)) {
        parseValue(jsonValue);
        return;
      }
    }
 else     if (contentHandler instanceof UnmarshalRecord && ((UnmarshalRecord)contentHandler).getXPathNode() != null) {
      if (!namespaceAware && localName.equals(Constants.SCHEMA_TYPE_ATTRIBUTE) && !((UnmarshalRecord)contentHandler).getXPathNode().hasTypeChild()) {
        return;
      }
      boolean isTextValue=isTextValue(localName);
      if (isTextValue) {
        parseValue(jsonValue);
        return;
      }
      NodeValue nv=((UnmarshalRecord)contentHandler).getAttributeChildNodeValue(uri,localName);
      if (attributePrefix == null && nv != null) {
        return;
      }
    }
    if (jsonValue != null && jsonValue.getValueType() == valueType.NULL) {
      contentHandler.setNil(true);
    }
    contentHandler.startElement(uri,localName,localName,attributes.setValue(jsonValue,attributePrefix,namespaces,namespaceSeparator,namespaceAware));
    parseValue(jsonValue);
    contentHandler.endElement(uri,localName,localName);
  }
}