Program: 66902
Project: 66902
Buggy source:
private void parseEvent(XMLEvent xmlEvent) throws SAXException {
  if (null == getContentHandler()) {
    return;
  }
switch (xmlEvent.getEventType()) {
case XMLEvent.ATTRIBUTE:
{
      break;
    }
case XMLEvent.CDATA:
{
    Characters characters=xmlEvent.asCharacters();
    if (null == lexicalHandler) {
      getContentHandler().characters(characters.getData().toCharArray(),0,characters.getData().length());
    }
 else {
      lexicalHandler.startCDATA();
      getContentHandler().characters(characters.getData().toCharArray(),0,characters.getData().length());
      lexicalHandler.endCDATA();
    }
    break;
  }
case XMLEvent.CHARACTERS:
{
  Characters characters=xmlEvent.asCharacters();
  getContentHandler().characters(characters.getData().toCharArray(),0,characters.getData().length());
  break;
}
case XMLEvent.COMMENT:
{
if (null != lexicalHandler) {
  Comment comment=(Comment)xmlEvent;
  lexicalHandler.comment(comment.getText().toCharArray(),0,comment.getText().length());
}
break;
}
case XMLEvent.DTD:
{
break;
}
case XMLEvent.END_DOCUMENT:
{
depth--;
return;
}
case XMLEvent.END_ELEMENT:
{
ArrayList declaredNs=this.namespaces.get(new Integer(depth));
depth--;
EndElement endElement=xmlEvent.asEndElement();
QName name=endElement.getName();
String prefix=endElement.getName().getPrefix();
if (null == prefix || prefix.length() == 0) {
getContentHandler().endElement(name.getNamespaceURI(),name.getLocalPart(),name.getLocalPart());
}
 else {
getContentHandler().endElement(name.getNamespaceURI(),name.getLocalPart(),prefix + XMLConstants.COLON + name.getLocalPart());
}
if (declaredNs != null) {
Iterator iter=declaredNs.iterator();
while (iter.hasNext()) {
Namespace next=(Namespace)iter.next();
getContentHandler().endPrefixMapping(next.getPrefix());
}
}
break;
}
case XMLEvent.ENTITY_DECLARATION:
{
break;
}
case XMLEvent.ENTITY_REFERENCE:
{
break;
}
case XMLEvent.NAMESPACE:
{
break;
}
case XMLEvent.NOTATION_DECLARATION:
{
break;
}
case XMLEvent.PROCESSING_INSTRUCTION:
{
ProcessingInstruction pi=(ProcessingInstruction)xmlEvent;
getContentHandler().processingInstruction(pi.getTarget(),pi.getData());
break;
}
case XMLEvent.SPACE:
{
char[] characters=xmlEvent.asCharacters().getData().toCharArray();
getContentHandler().characters(characters,0,characters.length);
break;
}
case XMLEvent.START_DOCUMENT:
{
depth++;
break;
}
case XMLEvent.START_ELEMENT:
{
depth++;
StartElement startElement=xmlEvent.asStartElement();
Iterator namespaces=startElement.getNamespaces();
ArrayList<Namespace> declaredNs=null;
if (namespaces.hasNext()) {
declaredNs=new ArrayList<Namespace>();
}
while (namespaces.hasNext()) {
Namespace next=(Namespace)namespaces.next();
getContentHandler().startPrefixMapping(next.getPrefix(),next.getNamespaceURI());
declaredNs.add(next);
}
if (declaredNs != null) {
this.namespaces.put(new Integer(depth),declaredNs);
}
QName qName=startElement.getName();
String prefix=qName.getPrefix();
if (null == prefix || prefix.length() == 0) {
getContentHandler().startElement(qName.getNamespaceURI(),qName.getLocalPart(),qName.getLocalPart(),new IndexedAttributeList(startElement.getAttributes(),startElement.getNamespaces()));
}
 else {
getContentHandler().startElement(qName.getNamespaceURI(),qName.getLocalPart(),prefix + XMLConstants.COLON + qName.getLocalPart(),new IndexedAttributeList(startElement.getAttributes(),startElement.getNamespaces()));
}
break;
}
}
}

Fixed version (ground truth):
private void parseEvent(XMLEvent xmlEvent) throws SAXException {
switch (xmlEvent.getEventType()) {
case XMLEvent.ATTRIBUTE:
{
      break;
    }
case XMLEvent.CDATA:
{
    Characters characters=xmlEvent.asCharacters();
    if (null == lexicalHandler) {
      contentHandler.characters(characters.getData().toCharArray(),0,characters.getData().length());
    }
 else {
      lexicalHandler.startCDATA();
      contentHandler.characters(characters.getData().toCharArray(),0,characters.getData().length());
      lexicalHandler.endCDATA();
    }
    break;
  }
case XMLEvent.CHARACTERS:
{
  char[] characters=xmlEvent.asCharacters().getData().toCharArray();
  contentHandler.characters(characters,0,characters.length);
  break;
}
case XMLEvent.COMMENT:
{
if (null != lexicalHandler) {
  char[] comment=((Comment)xmlEvent).getText().toCharArray();
  lexicalHandler.comment(comment,0,comment.length);
}
break;
}
case XMLEvent.DTD:
{
break;
}
case XMLEvent.END_DOCUMENT:
{
depth--;
return;
}
case XMLEvent.END_ELEMENT:
{
List<Namespace> declaredNs=this.namespaces.get(new Integer(depth));
depth--;
EndElement endElement=xmlEvent.asEndElement();
QName name=endElement.getName();
String prefix=endElement.getName().getPrefix();
if (null == prefix || prefix.length() == 0) {
contentHandler.endElement(name.getNamespaceURI(),name.getLocalPart(),name.getLocalPart());
}
 else {
contentHandler.endElement(name.getNamespaceURI(),name.getLocalPart(),prefix + XMLConstants.COLON + name.getLocalPart());
}
if (declaredNs != null) {
for (Namespace next : declaredNs) {
contentHandler.endPrefixMapping(next.getPrefix());
}
}
break;
}
case XMLEvent.ENTITY_DECLARATION:
{
break;
}
case XMLEvent.ENTITY_REFERENCE:
{
break;
}
case XMLEvent.NAMESPACE:
{
break;
}
case XMLEvent.NOTATION_DECLARATION:
{
break;
}
case XMLEvent.PROCESSING_INSTRUCTION:
{
ProcessingInstruction pi=(ProcessingInstruction)xmlEvent;
contentHandler.processingInstruction(pi.getTarget(),pi.getData());
break;
}
case XMLEvent.SPACE:
{
char[] characters=xmlEvent.asCharacters().getData().toCharArray();
contentHandler.characters(characters,0,characters.length);
break;
}
case XMLEvent.START_DOCUMENT:
{
depth++;
break;
}
case XMLEvent.START_ELEMENT:
{
depth++;
StartElement startElement=xmlEvent.asStartElement();
Iterator namespaces=startElement.getNamespaces();
List<Namespace> declaredNs=null;
if (namespaces.hasNext()) {
declaredNs=new ArrayList<Namespace>();
}
while (namespaces.hasNext()) {
Namespace next=(Namespace)namespaces.next();
contentHandler.startPrefixMapping(next.getPrefix(),next.getNamespaceURI());
declaredNs.add(next);
}
if (declaredNs != null) {
this.namespaces.put(new Integer(depth),declaredNs);
}
QName qName=startElement.getName();
String prefix=qName.getPrefix();
if (null == prefix || prefix.length() == 0) {
contentHandler.startElement(qName.getNamespaceURI(),qName.getLocalPart(),qName.getLocalPart(),new IndexedAttributeList(startElement.getAttributes(),startElement.getNamespaces()));
}
 else {
contentHandler.startElement(qName.getNamespaceURI(),qName.getLocalPart(),prefix + XMLConstants.COLON + qName.getLocalPart(),new IndexedAttributeList(startElement.getAttributes(),startElement.getNamespaces()));
}
break;
}
}
}