Program: 51221
Project: 51221
Buggy source:
private void readNext(boolean checkAttributesOnly) throws IOException {
  if (!checkAttributesOnly) {
    eventQueue.poll();
  }
  while (eventQueue.isEmpty() || checkAttributesOnly) {
    lastToken=nextToken();
    if ((null == lastToken) || (LaState.END == processingStack.get(depth).state)) {
      if (jsonRootUnwrapping) {
        generateEEEvent(processingStack.get(depth).lastName);
      }
      eventQueue.add(new EndDocumentEvent(new StaxLocation(lexer)));
      break;
    }
switch (processingStack.get(depth).state) {
case START:
      if (0 == depth) {
        eventQueue.add(new StartDocumentEvent(new StaxLocation(lexer)));
        processingStack.get(depth).state=LaState.AFTER_OBJ_START_BRACE;
        if (jsonRootUnwrapping) {
          processingStack.get(depth).lastName=this.rootElementName;
          StartElementEvent event=generateSEEvent(processingStack.get(depth).lastName);
          processingStack.get(depth).eventToReadAttributesFor=event;
        }
switch (lastToken.tokenType) {
case JsonToken.START_OBJECT:
          processingStack.add(new ProcessingState(LaState.AFTER_OBJ_START_BRACE));
        depth++;
      break;
case JsonToken.START_ARRAY:
    processingStack.add(new ProcessingState(LaState.AFTER_ARRAY_START_BRACE));
  depth++;
break;
case JsonToken.STRING:
case JsonToken.NUMBER:
case JsonToken.TRUE:
case JsonToken.FALSE:
case JsonToken.NULL:
eventQueue.add(new CharactersEvent(lastToken.tokenText,new StaxLocation(lexer)));
processingStack.get(depth).state=LaState.END;
break;
default :
}
}
processingStack.get(depth).state=LaState.AFTER_OBJ_START_BRACE;
break;
case AFTER_OBJ_START_BRACE:
switch (lastToken.tokenType) {
case JsonToken.STRING:
if (lastToken.tokenText.startsWith("String_Node_Str") || attrAsElemNames.contains(lastToken.tokenText)) {
String attrName=lastToken.tokenText.startsWith("String_Node_Str") ? lastToken.tokenText : ("String_Node_Str" + lastToken.tokenText);
colon();
lastToken=nextToken();
if (!valueTokenTypes.contains(lastToken.tokenType)) {
throw new IOException("String_Node_Str" + lastToken.tokenText + "String_Node_Str");
}
if (null != processingStack.get(depth - 1).eventToReadAttributesFor) {
processingStack.get(depth - 1).eventToReadAttributesFor.addAttribute(createQName(attrName.substring(1)),lastToken.tokenText);
}
lastToken=nextToken();
switch (lastToken.tokenType) {
case JsonToken.END_OBJECT:
processingStack.remove(depth);
depth--;
valueRead();
checkAttributesOnly=false;
break;
case JsonToken.COMMA:
break;
default :
throw new IOException("String_Node_Str" + lastToken.tokenText + "String_Node_Str");
}
}
 else {
StartElementEvent event=generateSEEvent(lastToken.tokenText);
processingStack.get(depth).eventToReadAttributesFor=event;
checkAttributesOnly=false;
processingStack.get(depth).lastName=lastToken.tokenText;
colon();
processingStack.get(depth).state=LaState.BEFORE_VALUE_IN_KV_PAIR;
}
break;
case JsonToken.END_OBJECT:
generateEEEvent(processingStack.get(depth).lastName);
checkAttributesOnly=false;
processingStack.remove(depth);
depth--;
break;
default :
}
break;
case BEFORE_OBJ_NEXT_KV_PAIR:
switch (lastToken.tokenType) {
case JsonToken.STRING:
StartElementEvent event=generateSEEvent(lastToken.tokenText);
processingStack.get(depth).eventToReadAttributesFor=event;
processingStack.get(depth).lastName=lastToken.tokenText;
colon();
processingStack.get(depth).state=LaState.BEFORE_VALUE_IN_KV_PAIR;
break;
default :
}
break;
case BEFORE_VALUE_IN_KV_PAIR:
switch (lastToken.tokenType) {
case JsonToken.START_OBJECT:
processingStack.add(new ProcessingState(LaState.AFTER_OBJ_START_BRACE));
depth++;
break;
case JsonToken.START_ARRAY:
processingStack.add(new ProcessingState(LaState.AFTER_ARRAY_START_BRACE));
depth++;
break;
case JsonToken.STRING:
case JsonToken.NUMBER:
case JsonToken.TRUE:
case JsonToken.FALSE:
case JsonToken.NULL:
eventQueue.add(new CharactersEvent(lastToken.tokenText,new StaxLocation(lexer)));
processingStack.get(depth).state=LaState.AFTER_OBJ_KV_PAIR;
break;
default :
}
break;
case AFTER_OBJ_KV_PAIR:
switch (lastToken.tokenType) {
case JsonToken.COMMA:
processingStack.get(depth).state=LaState.BEFORE_OBJ_NEXT_KV_PAIR;
generateEEEvent(processingStack.get(depth).lastName);
break;
case JsonToken.END_OBJECT:
generateEEEvent(processingStack.get(depth).lastName);
processingStack.remove(depth);
depth--;
valueRead();
break;
default :
}
break;
case AFTER_ARRAY_START_BRACE:
switch (lastToken.tokenType) {
case JsonToken.START_OBJECT:
processingStack.add(new ProcessingState(LaState.AFTER_OBJ_START_BRACE));
processingStack.get(depth).eventToReadAttributesFor=processingStack.get(depth - 1).eventToReadAttributesFor;
depth++;
break;
case JsonToken.START_ARRAY:
processingStack.add(new ProcessingState(LaState.AFTER_ARRAY_START_BRACE));
depth++;
break;
case JsonToken.END_ARRAY:
processingStack.remove(depth);
depth--;
valueRead();
break;
case JsonToken.STRING:
eventQueue.add(new CharactersEvent(lastToken.tokenText,new StaxLocation(lexer)));
processingStack.get(depth).state=LaState.AFTER_ARRAY_ELEM;
break;
default :
}
break;
case BEFORE_NEXT_ARRAY_ELEM:
StartElementEvent event=generateSEEvent(processingStack.get(depth - 1).lastName);
switch (lastToken.tokenType) {
case JsonToken.START_OBJECT:
processingStack.add(new ProcessingState(LaState.AFTER_OBJ_START_BRACE));
processingStack.get(depth).eventToReadAttributesFor=event;
depth++;
break;
case JsonToken.START_ARRAY:
processingStack.add(new ProcessingState(LaState.AFTER_ARRAY_START_BRACE));
depth++;
break;
case JsonToken.STRING:
eventQueue.add(new CharactersEvent(lastToken.tokenText,new StaxLocation(lexer)));
processingStack.get(depth).state=LaState.AFTER_ARRAY_ELEM;
break;
default :
}
break;
case AFTER_ARRAY_ELEM:
switch (lastToken.tokenType) {
case JsonToken.END_ARRAY:
processingStack.remove(depth);
depth--;
valueRead();
break;
case JsonToken.COMMA:
processingStack.get(depth).state=LaState.BEFORE_NEXT_ARRAY_ELEM;
generateEEEvent(processingStack.get(depth - 1).lastName);
break;
default :
}
break;
}
}
}

Fixed version (ground truth):
private void readNext(boolean checkAttributesOnly) throws IOException {
  if (!checkAttributesOnly) {
    eventQueue.poll();
  }
  while (eventQueue.isEmpty() || checkAttributesOnly) {
    lastToken=nextToken();
    if ((null == lastToken) || (LaState.END == processingStack.get(depth).state)) {
      if (jsonRootUnwrapping) {
        generateEEEvent(processingStack.get(depth).lastName);
      }
      eventQueue.add(new EndDocumentEvent(new StaxLocation(lexer)));
      break;
    }
switch (processingStack.get(depth).state) {
case START:
      if (0 == depth) {
        eventQueue.add(new StartDocumentEvent(new StaxLocation(lexer)));
        processingStack.get(depth).state=LaState.AFTER_OBJ_START_BRACE;
        if (jsonRootUnwrapping) {
          processingStack.get(depth).lastName=this.rootElementName;
          StartElementEvent event=generateSEEvent(processingStack.get(depth).lastName);
          processingStack.get(depth).eventToReadAttributesFor=event;
        }
switch (lastToken.tokenType) {
case JsonToken.START_OBJECT:
          processingStack.add(new ProcessingState(LaState.AFTER_OBJ_START_BRACE));
        depth++;
      break;
case JsonToken.START_ARRAY:
    processingStack.add(new ProcessingState(LaState.AFTER_ARRAY_START_BRACE));
  depth++;
break;
case JsonToken.STRING:
case JsonToken.NUMBER:
case JsonToken.TRUE:
case JsonToken.FALSE:
case JsonToken.NULL:
eventQueue.add(new CharactersEvent(lastToken.tokenText,new StaxLocation(lexer)));
processingStack.get(depth).state=LaState.END;
break;
default :
}
}
processingStack.get(depth).state=LaState.AFTER_OBJ_START_BRACE;
break;
case AFTER_OBJ_START_BRACE:
switch (lastToken.tokenType) {
case JsonToken.STRING:
if (lastToken.tokenText.startsWith("String_Node_Str") || attrAsElemNames.contains(lastToken.tokenText)) {
String attrName=lastToken.tokenText.startsWith("String_Node_Str") ? lastToken.tokenText : ("String_Node_Str" + lastToken.tokenText);
colon();
lastToken=nextToken();
if (!valueTokenTypes.contains(lastToken.tokenType)) {
throw new IOException("String_Node_Str" + lastToken.tokenText + "String_Node_Str");
}
if (null != processingStack.get(depth - 1).eventToReadAttributesFor) {
processingStack.get(depth - 1).eventToReadAttributesFor.addAttribute(createQName(attrName.substring(1)),lastToken.tokenText);
}
lastToken=nextToken();
switch (lastToken.tokenType) {
case JsonToken.END_OBJECT:
processingStack.remove(depth);
depth--;
valueRead();
checkAttributesOnly=false;
break;
case JsonToken.COMMA:
break;
default :
throw new IOException("String_Node_Str" + lastToken.tokenText + "String_Node_Str");
}
}
 else {
StartElementEvent event=generateSEEvent(lastToken.tokenText);
processingStack.get(depth).eventToReadAttributesFor=event;
checkAttributesOnly=false;
processingStack.get(depth).lastName=lastToken.tokenText;
colon();
processingStack.get(depth).state=LaState.BEFORE_VALUE_IN_KV_PAIR;
}
break;
case JsonToken.END_OBJECT:
generateEEEvent(processingStack.get(depth).lastName);
checkAttributesOnly=false;
processingStack.remove(depth);
depth--;
valueRead();
break;
default :
}
break;
case BEFORE_OBJ_NEXT_KV_PAIR:
switch (lastToken.tokenType) {
case JsonToken.STRING:
StartElementEvent event=generateSEEvent(lastToken.tokenText);
processingStack.get(depth).eventToReadAttributesFor=event;
processingStack.get(depth).lastName=lastToken.tokenText;
colon();
processingStack.get(depth).state=LaState.BEFORE_VALUE_IN_KV_PAIR;
break;
default :
}
break;
case BEFORE_VALUE_IN_KV_PAIR:
switch (lastToken.tokenType) {
case JsonToken.START_OBJECT:
processingStack.add(new ProcessingState(LaState.AFTER_OBJ_START_BRACE));
depth++;
break;
case JsonToken.START_ARRAY:
processingStack.add(new ProcessingState(LaState.AFTER_ARRAY_START_BRACE));
depth++;
break;
case JsonToken.STRING:
case JsonToken.NUMBER:
case JsonToken.TRUE:
case JsonToken.FALSE:
case JsonToken.NULL:
eventQueue.add(new CharactersEvent(lastToken.tokenText,new StaxLocation(lexer)));
processingStack.get(depth).state=LaState.AFTER_OBJ_KV_PAIR;
break;
default :
}
break;
case AFTER_OBJ_KV_PAIR:
switch (lastToken.tokenType) {
case JsonToken.COMMA:
processingStack.get(depth).state=LaState.BEFORE_OBJ_NEXT_KV_PAIR;
generateEEEvent(processingStack.get(depth).lastName);
break;
case JsonToken.END_OBJECT:
generateEEEvent(processingStack.get(depth).lastName);
processingStack.remove(depth);
depth--;
valueRead();
break;
default :
}
break;
case AFTER_ARRAY_START_BRACE:
switch (lastToken.tokenType) {
case JsonToken.START_OBJECT:
processingStack.add(new ProcessingState(LaState.AFTER_OBJ_START_BRACE));
processingStack.get(depth).eventToReadAttributesFor=processingStack.get(depth - 1).eventToReadAttributesFor;
depth++;
break;
case JsonToken.START_ARRAY:
processingStack.add(new ProcessingState(LaState.AFTER_ARRAY_START_BRACE));
depth++;
break;
case JsonToken.END_ARRAY:
processingStack.remove(depth);
depth--;
valueRead();
break;
case JsonToken.STRING:
eventQueue.add(new CharactersEvent(lastToken.tokenText,new StaxLocation(lexer)));
processingStack.get(depth).state=LaState.AFTER_ARRAY_ELEM;
break;
default :
}
break;
case BEFORE_NEXT_ARRAY_ELEM:
StartElementEvent event=generateSEEvent(processingStack.get(depth - 1).lastName);
switch (lastToken.tokenType) {
case JsonToken.START_OBJECT:
processingStack.add(new ProcessingState(LaState.AFTER_OBJ_START_BRACE));
processingStack.get(depth).eventToReadAttributesFor=event;
depth++;
break;
case JsonToken.START_ARRAY:
processingStack.add(new ProcessingState(LaState.AFTER_ARRAY_START_BRACE));
depth++;
break;
case JsonToken.STRING:
eventQueue.add(new CharactersEvent(lastToken.tokenText,new StaxLocation(lexer)));
processingStack.get(depth).state=LaState.AFTER_ARRAY_ELEM;
break;
default :
}
break;
case AFTER_ARRAY_ELEM:
switch (lastToken.tokenType) {
case JsonToken.END_ARRAY:
processingStack.remove(depth);
depth--;
valueRead();
break;
case JsonToken.COMMA:
processingStack.get(depth).state=LaState.BEFORE_NEXT_ARRAY_ELEM;
generateEEEvent(processingStack.get(depth - 1).lastName);
break;
default :
}
break;
}
}
}