Program: 87062
Project: 87062
Buggy source:
/** 
 * Parses a single line in the authz file.
 * @param lineNumber Number of the line being processed.
 * @param line Content of the line.
 * @throws ParserException
 * @throws ApplicationException
 */
private static void parseLine(int lineNumber,String line) throws ParserException, ApplicationException {
switch (line.charAt(0)) {
case '#':
    break;
case '[':
  if (line.equals("String_Node_Str")) {
    if (currentState != STATE_START) {
      throw ParserException.generateException(lineNumber,ResourceUtil.getString("String_Node_Str"));
    }
    currentState=STATE_PROCESS_GROUPS;
  }
 else   if (line.indexOf(':') == -1) {
    currentState=STATE_PROCESS_SERVER_RULES;
    String path=line.substring(1,line.length() - 1).trim();
    if (Document.findServerPath(path) != null) {
      throw ParserException.generateException(lineNumber,ResourceUtil.getFormattedString("String_Node_Str",path));
    }
    try {
      currentPath=Document.addPath(null,path);
    }
 catch (    ApplicationException ae) {
      throw ParserException.generateException(lineNumber,ae.getMessage());
    }
  }
 else   if (line.indexOf(':') >= 0) {
    currentState=STATE_PROCESS_RULES;
    int index=line.indexOf(':');
    String repository=line.substring(1,index).trim();
    String path=line.substring(index + 1,line.length() - 1).trim();
    Repository repositoryObject=null;
    try {
      repositoryObject=Document.addRepository(repository);
    }
 catch (    ApplicationException ae) {
      throw ParserException.generateException(lineNumber,ae.getMessage());
    }
    if (Document.findPath(repositoryObject,path) != null) {
      Object[] args=new Object[2];
      args[0]=path;
      args[1]=repository;
      throw ParserException.generateException(lineNumber,ResourceUtil.getFormattedString("String_Node_Str",args));
    }
    try {
      currentPath=Document.addPath(repositoryObject,path);
    }
 catch (    ApplicationException ae) {
      throw ParserException.generateException(lineNumber,ae.getMessage());
    }
  }
 else {
    throw ParserException.generateException(lineNumber,ResourceUtil.getString("String_Node_Str"));
  }
break;
case '@':
if (currentState == STATE_PROCESS_RULES || currentState == STATE_PROCESS_SERVER_RULES) {
int index=line.indexOf('=');
String group=line.substring(1,index).trim();
String level=line.substring(index + 1).trim();
if (Document.findGroup(group) == null) {
  throw ParserException.generateException(lineNumber,ResourceUtil.getFormattedString("String_Node_Str",group));
}
try {
  Document.addAccessRuleForGroup(currentPath,group,level);
}
 catch (ApplicationException ae) {
  throw ParserException.generateException(lineNumber,ae.getMessage());
}
}
 else {
throw ParserException.generateException(lineNumber,ResourceUtil.getString("String_Node_Str"));
}
break;
default :
if (currentState == STATE_PROCESS_GROUPS) {
int index=line.indexOf('=');
if (index == -1) {
throw ParserException.generateException(lineNumber,ResourceUtil.getString("String_Node_Str"));
}
String name=line.substring(0,index).trim();
String members=line.substring(index + 1).trim();
StringTokenizer tokens=new StringTokenizer(members,"String_Node_Str");
int memberCount=tokens.countTokens();
List<String> groupMembers=new ArrayList<String>();
List<String> userMembers=new ArrayList<String>();
for (int i=0; i < memberCount; i++) {
String member=tokens.nextToken();
if (member.charAt(0) == '@') {
groupMembers.add(member.substring(1,member.length()));
}
 else {
userMembers.add(member);
}
}
if (Document.findGroup(name) != null) {
throw ParserException.generateException(lineNumber,ResourceUtil.getFormattedString("String_Node_Str",name));
}
try {
Document.addGroupByName(name,groupMembers,userMembers);
}
 catch (ApplicationException ae) {
throw ParserException.generateException(lineNumber,ae.getMessage());
}
}
 else if (currentState == STATE_PROCESS_RULES || currentState == STATE_PROCESS_SERVER_RULES) {
int index=line.indexOf('=');
String user=line.substring(0,index).trim();
String level=line.substring(index + 1).trim();
try {
Document.addAccessRuleForUser(currentPath,user,level);
}
 catch (ApplicationException ae) {
throw ParserException.generateException(lineNumber,ae.getMessage());
}
}
break;
}
}

Fixed version (ground truth):
/** 
 * Parses a single line in the authz file.
 * @param lineNumber Number of the line being processed.
 * @param line Content of the line.
 * @throws ParserException
 * @throws ApplicationException
 */
private static void parseLine(int lineNumber,String line) throws ParserException, ApplicationException {
switch (line.charAt(0)) {
case '#':
    break;
case '[':
  if (line.equals("String_Node_Str")) {
    if (currentState != STATE_START) {
      throw ParserException.generateException(lineNumber,ResourceUtil.getString("String_Node_Str"));
    }
    currentState=STATE_PROCESS_GROUPS;
  }
 else   if (line.indexOf(':') == -1) {
    currentState=STATE_PROCESS_SERVER_RULES;
    String path=line.substring(1,line.length() - 1).trim();
    if (Document.findServerPath(path) != null) {
      throw ParserException.generateException(lineNumber,ResourceUtil.getFormattedString("String_Node_Str",path));
    }
    try {
      currentPath=Document.addPath(null,path);
    }
 catch (    ApplicationException ae) {
      throw ParserException.generateException(lineNumber,ae.getMessage());
    }
  }
 else   if (line.indexOf(':') >= 0) {
    currentState=STATE_PROCESS_RULES;
    int index=line.indexOf(':');
    String repository=line.substring(1,index).trim();
    String path=line.substring(index + 1,line.length() - 1).trim();
    Repository repositoryObject=null;
    try {
      repositoryObject=Document.addRepository(repository);
    }
 catch (    ApplicationException ae) {
      throw ParserException.generateException(lineNumber,ae.getMessage());
    }
    if (Document.findPath(repositoryObject,path) != null) {
      Object[] args=new Object[2];
      args[0]=path;
      args[1]=repository;
      throw ParserException.generateException(lineNumber,ResourceUtil.getFormattedString("String_Node_Str",args));
    }
    try {
      currentPath=Document.addPath(repositoryObject,path);
    }
 catch (    ApplicationException ae) {
      throw ParserException.generateException(lineNumber,ae.getMessage());
    }
  }
 else {
    throw ParserException.generateException(lineNumber,ResourceUtil.getString("String_Node_Str"));
  }
break;
case '@':
if (currentState == STATE_PROCESS_RULES || currentState == STATE_PROCESS_SERVER_RULES) {
int index=line.indexOf('=');
String group=line.substring(1,index).trim();
String level=line.substring(index + 1).trim();
if (Document.findGroup(group) == null) {
  throw ParserException.generateException(lineNumber,ResourceUtil.getFormattedString("String_Node_Str",group));
}
try {
  Document.addAccessRuleForGroup(currentPath,group,level);
}
 catch (ApplicationException ae) {
  throw ParserException.generateException(lineNumber,ae.getMessage());
}
}
 else {
throw ParserException.generateException(lineNumber,ResourceUtil.getString("String_Node_Str"));
}
break;
default :
if (currentState == STATE_PROCESS_GROUPS) {
int index=line.indexOf('=');
if (index == -1) {
throw ParserException.generateException(lineNumber,ResourceUtil.getString("String_Node_Str"));
}
String name=line.substring(0,index).trim();
String members=line.substring(index + 1).trim();
StringTokenizer tokens=new StringTokenizer(members,"String_Node_Str");
int memberCount=tokens.countTokens();
List<String> groupMembers=new ArrayList<String>();
List<String> userMembers=new ArrayList<String>();
for (int i=0; i < memberCount; i++) {
String member=tokens.nextToken();
if (member.charAt(0) == '@') {
groupMembers.add(member.substring(1,member.length()));
}
 else {
userMembers.add(member);
}
}
Group existingGroup=Document.findGroup(name);
if (existingGroup == null) {
try {
Document.addGroupByName(name,groupMembers,userMembers);
}
 catch (ApplicationException ae) {
throw ParserException.generateException(lineNumber,ae.getMessage());
}
}
 else {
if (existingGroup.getGroupMembers().isEmpty() && existingGroup.getUserMembers().isEmpty()) {
Document.addMembersByName(existingGroup,groupMembers,userMembers);
}
 else {
throw ParserException.generateException(lineNumber,ResourceUtil.getFormattedString("String_Node_Str",name));
}
}
}
 else if (currentState == STATE_PROCESS_RULES || currentState == STATE_PROCESS_SERVER_RULES) {
int index=line.indexOf('=');
String user=line.substring(0,index).trim();
String level=line.substring(index + 1).trim();
try {
Document.addAccessRuleForUser(currentPath,user,level);
}
 catch (ApplicationException ae) {
throw ParserException.generateException(lineNumber,ae.getMessage());
}
}
break;
}
}