Program: 51328
Project: 51328
Buggy source:
private void readNext(boolean checkAttributesOnly) throws IOException {
  if (!checkAttributesOnly) {
    eventQueue.poll();
  }
  while (eventQueue.isEmpty() || checkAttributesOnly) {
    lastToken=nextToken();
    if (null == lastToken) {
      if (jsonRootUnwrapping) {
        eventQueue.add(new EndElementEvent(processingStack.get(depth).lastName,new MyLocation(lexer)));
      }
      eventQueue.add(new EndDocumentEvent(new MyLocation(lexer)));
      break;
    }
switch (processingStack.get(depth).state) {
case START:
      if (0 == depth) {
        eventQueue.add(new StartDocumentEvent(new MyLocation(lexer)));
        processingStack.get(depth).state=LaState.AFTER_OBJ_START_BRACE;
        if (jsonRootUnwrapping) {
          processingStack.get(depth).lastName="String_Node_Str";
          StartElementEvent event=new StartElementEvent(processingStack.get(depth).lastName,new MyLocation(lexer));
          eventQueue.add(event);
          processingStack.get(depth).eventToReadAttributesFor=event;
        }
        if (JsonToken.NULL != lastToken.tokenType) {
          processingStack.add(new ProcessingState());
          depth++;
        }
      }
    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")) {
    String attrName=lastToken.tokenText;
    colon();
    lastToken=nextToken();
    if (JsonToken.STRING != 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(attrName.substring(1),lastToken.tokenText);
    }
    lastToken=nextToken();
switch (lastToken.tokenType) {
case JsonToken.END_OBJECT:
      eventQueue.add(new EndElementEvent(processingStack.get(depth).lastName,new MyLocation(lexer)));
    processingStack.remove(depth);
  depth--;
break;
case JsonToken.COMMA:
break;
default :
throw new IOException("String_Node_Str" + lastToken.tokenText + "String_Node_Str");
}
}
 else {
StartElementEvent event=new StartElementEvent(lastToken.tokenText,new MyLocation(lexer));
eventQueue.add(event);
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:
eventQueue.add(new EndElementEvent(processingStack.get(depth).lastName,new MyLocation(lexer)));
checkAttributesOnly=false;
processingStack.remove(depth);
depth--;
break;
default :
}
break;
case BEFORE_OBJ_NEXT_KV_PAIR:
switch (lastToken.tokenType) {
case JsonToken.STRING:
StartElementEvent event=new StartElementEvent(lastToken.tokenText,new MyLocation(lexer));
eventQueue.add(event);
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 MyLocation(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;
eventQueue.add(new EndElementEvent(processingStack.get(depth).lastName,new MyLocation(lexer)));
break;
case JsonToken.END_OBJECT:
eventQueue.add(new EndElementEvent(processingStack.get(depth).lastName,new MyLocation(lexer)));
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 MyLocation(lexer)));
processingStack.get(depth).state=LaState.AFTER_ARRAY_ELEM;
break;
default :
}
break;
case BEFORE_NEXT_ARRAY_ELEM:
StartElementEvent event=new StartElementEvent(processingStack.get(depth - 1).lastName,new MyLocation(lexer));
eventQueue.add(event);
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 MyLocation(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;
eventQueue.add(new EndElementEvent(processingStack.get(depth - 1).lastName,new MyLocation(lexer)));
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 MyLocation(lexer)));
      break;
    }
switch (processingStack.get(depth).state) {
case START:
      if (0 == depth) {
        eventQueue.add(new StartDocumentEvent(new MyLocation(lexer)));
        processingStack.get(depth).state=LaState.AFTER_OBJ_START_BRACE;
        if (jsonRootUnwrapping) {
          processingStack.get(depth).lastName="String_Node_Str";
          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 MyLocation(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")) {
String attrName=lastToken.tokenText;
colon();
lastToken=nextToken();
if (JsonToken.STRING != 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(attrName.substring(1),lastToken.tokenText);
}
lastToken=nextToken();
switch (lastToken.tokenType) {
case JsonToken.END_OBJECT:
generateEEEvent(processingStack.get(depth).lastName);
processingStack.remove(depth);
depth--;
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 MyLocation(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 MyLocation(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 MyLocation(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;
}
}
}