Program: 28187
Project: 28187
Buggy source:
private LinkedList<String> parsePattern(String pattern){
  LinkedList<String> list=new LinkedList<String>();
  int from=0;
  int end=-1;
  int index=-1;
  boolean errorInPattern=false;
  if (pattern == null || pattern.indexOf('%') < 0) {
    _logger.log(Level.SEVERE,ACCESS_LOG_VALVE_INVALID_ACCESS_LOG_PATTERN,pattern);
    errorInPattern=true;
  }
  while ((index=pattern.indexOf('%',from)) >= 0) {
    end=pattern.indexOf('%',index + 1);
    if (end < 0) {
      _logger.log(Level.SEVERE,MISSING_ACCESS_LOG_PATTERN_END_DELIMITER,pattern);
      errorInPattern=true;
      break;
    }
    String component=pattern.substring(index + 1,end);
    if (!component.startsWith(ATTRIBUTE_BY_NAME_PREFIX) && !AUTH_USER_NAME.equals(component) && !CLIENT_DNS.equals(component)&& !CLIENT_NAME.equals(component)&& !COOKIE.equals(component)&& !COOKIES.equals(component)&& !COOKIE_VALUE.equals(component)&& !component.startsWith(COOKIE_BY_NAME_PREFIX)&& !component.startsWith(COOKIES_BY_NAME_PREFIX)&& !DATE_TIME.equals(component)&& !HEADER_ACCEPT.equals(component)&& !HEADER_AUTH.equals(component)&& !HEADER_DATE.equals(component)&& !HEADER_IF_MOD_SINCE.equals(component)&& !HEADER_USER_AGENT.equals(component)&& !HEADER_REFERER.equals(component)&& !HTTP_METHOD.equals(component)&& !HTTP_URI.equals(component)&& !HTTP_VERSION.equals(component)&& !QUERY_STR.equals(component)&& !REFERER.equals(component)&& !REQUEST.equals(component)&& !RESPONSE_LENGTH.equals(component)&& !RESPONSE_CONTENT_TYPE.equals(component)&& !STATUS.equals(component)&& !TIME_TAKEN.equals(component)&& !USER_AGENT.equals(component)&& !VS_ID.equals(component)&& !component.startsWith(HEADER_BY_NAME_PREFIX)&& !component.startsWith(HEADERS_BY_NAME_PREFIX)&& !component.startsWith(RESPONSE_HEADER_BY_NAME_PREFIX)&& !component.startsWith(RESPONSE_HEADERS_BY_NAME_PREFIX)) {
      _logger.log(Level.SEVERE,INVALID_ACCESS_LOG_PATTERN_COMPONENT,new Object[]{component,pattern});
      errorInPattern=true;
    }
    if (TIME_TAKEN.equals(component)) {
      needTimeTaken=true;
    }
    list.add(component);
    from=end + 1;
  }
  if (errorInPattern) {
    return null;
  }
 else {
    return list;
  }
}

Fixed version (ground truth):
private LinkedList<String> parsePattern(String pattern){
  LinkedList<String> list=new LinkedList<String>();
  int from=0;
  int end=-1;
  int index=-1;
  boolean errorInPattern=false;
  if (pattern == null || pattern.indexOf('%') < 0) {
    _logger.log(Level.SEVERE,ACCESS_LOG_VALVE_INVALID_ACCESS_LOG_PATTERN,pattern);
    errorInPattern=true;
  }
  while ((index=pattern.indexOf('%',from)) >= 0) {
    end=pattern.indexOf('%',index + 1);
    if (end < 0) {
      _logger.log(Level.SEVERE,MISSING_ACCESS_LOG_PATTERN_END_DELIMITER,pattern);
      errorInPattern=true;
      break;
    }
    String component=pattern.substring(index + 1,end);
    if (!component.startsWith(ATTRIBUTE_BY_NAME_PREFIX) && !AUTH_USER_NAME.equals(component) && !CLIENT_DNS.equals(component)&& !CLIENT_NAME.equals(component)&& !COOKIE.equals(component)&& !COOKIES.equals(component)&& !COOKIE_VALUE.equals(component)&& !component.startsWith(COOKIE_BY_NAME_PREFIX)&& !component.startsWith(COOKIES_BY_NAME_PREFIX)&& !DATE_TIME.equals(component)&& !HEADER_ACCEPT.equals(component)&& !HEADER_AUTH.equals(component)&& !HEADER_DATE.equals(component)&& !HEADER_IF_MOD_SINCE.equals(component)&& !HEADER_USER_AGENT.equals(component)&& !HEADER_REFERER.equals(component)&& !HTTP_METHOD.equals(component)&& !HTTP_URI.equals(component)&& !HTTP_VERSION.equals(component)&& !QUERY_STR.equals(component)&& !REFERER.equals(component)&& !REQUEST.equals(component)&& !RESPONSE_LENGTH.equals(component)&& !RESPONSE_CONTENT_TYPE.equals(component)&& !STATUS.equals(component)&& !TIME_TAKEN.equals(component)&& !USER_AGENT.equals(component)&& !VS_ID.equals(component)&& !component.startsWith(HEADER_BY_NAME_PREFIX)&& !component.startsWith(HEADERS_BY_NAME_PREFIX)&& !component.startsWith(RESPONSE_HEADER_BY_NAME_PREFIX)&& !component.startsWith(RESPONSE_HEADERS_BY_NAME_PREFIX)&& !component.startsWith(SESSION_ATTRIBUTE_BY_NAME_PREFIX)) {
      _logger.log(Level.SEVERE,INVALID_ACCESS_LOG_PATTERN_COMPONENT,new Object[]{component,pattern});
      errorInPattern=true;
    }
    if (TIME_TAKEN.equals(component)) {
      needTimeTaken=true;
    }
    list.add(component);
    from=end + 1;
  }
  if (errorInPattern) {
    return null;
  }
 else {
    return list;
  }
}