Program: 53839
Project: 53839
Buggy source:
/** 
 * Generate code for one list pattern.
 * @param logger logger to use for error/warning messages
 * @param locale locale we are generating code for
 * @param listArg the {n,list,...} argument in the original format pattern
 * @param val0 the expression defining the {0} argument in the list pattern
 * @param val1 the expression defining the {1} argument in the list pattern
 * @param elemType the element type of the list/array being rendered as a list* @param isSafeHtml true if the resulting string is SafeHtml
 * @param listPattern the list pattern to generate code for, ie "{0}, {1}"
 * @param formatSecond true if the {1} parameter needs to be formatted
 * @param params parameters passed to the Messages method call
 * @return a constructed string containing the code to implement the givenlist pattern
 * @throws UnableToCompleteException
 */
private CharSequence formatListPattern(final TreeLogger logger,final GwtLocale locale,final ArgumentChunk listArg,final String val0,final String val1,final JType elemType,final boolean isSafeHtml,String listPattern,final boolean formatSecond,final Parameters params) throws UnableToCompleteException {
  final StringBuffer buf=new StringBuffer();
  final StringGenerator gen=new StringGenerator(buf,isSafeHtml);
  try {
    List<TemplateChunk> chunks=MessageFormatParser.parse(listPattern);
    for (    TemplateChunk chunk : chunks) {
      chunk.accept(new DefaultTemplateChunkVisitor(){
        @Override public void visit(        ArgumentChunk argChunk) throws UnableToCompleteException {
          if (argChunk.getArgumentNumber() == 0 || formatSecond) {
            formatArg(logger,locale,gen,listArg,argChunk.getArgumentNumber() == 0 ? val0 : val1,elemType,params);
          }
 else {
            gen.appendExpression(val1,isSafeHtml,false,false);
          }
        }
        @Override public void visit(        StringChunk stringChunk) throws UnableToCompleteException {
          gen.appendStringLiteral(stringChunk.getString());
        }
      }
);
    }
  }
 catch (  ParseException e) {
    logger.log(TreeLogger.ERROR,"String_Node_Str" + listPattern + "String_Node_Str"+ locale,e);
    throw new UnableToCompleteException();
  }
  gen.completeString();
  return buf;
}

Fixed version (ground truth):
/** 
 * Generate code for one list pattern.
 * @param logger logger to use for error/warning messages
 * @param locale locale we are generating code for
 * @param listArg the {n,list,...} argument in the original format pattern
 * @param val0 the expression defining the {0} argument in the list pattern
 * @param val1 the expression defining the {1} argument in the list pattern
 * @param elemType the element type of the list/array being rendered as a list* @param isSafeHtml true if the resulting string is SafeHtml
 * @param listPattern the list pattern to generate code for, ie "{0}, {1}"
 * @param formatSecond true if the {1} parameter needs to be formatted
 * @param params parameters passed to the Messages method call
 * @return a constructed string containing the code to implement the givenlist pattern
 * @throws UnableToCompleteException
 */
private CharSequence formatListPattern(final TreeLogger logger,final GwtLocale locale,final ArgumentChunk listArg,final String val0,final String val1,final JType elemType,final boolean isSafeHtml,String listPattern,final boolean formatSecond,final Parameters params) throws UnableToCompleteException {
  final StringBuffer buf=new StringBuffer();
  final StringGenerator gen=new StringGenerator(buf,isSafeHtml);
  try {
    List<TemplateChunk> chunks=MessageFormatParser.parse(listPattern);
    for (    TemplateChunk chunk : chunks) {
      chunk.accept(new DefaultTemplateChunkVisitor(){
        @Override public void visit(        ArgumentChunk argChunk) throws UnableToCompleteException {
          if (argChunk.getArgumentNumber() == 0 || formatSecond) {
            formatArg(logger,locale,gen,listArg,argChunk.getArgumentNumber() == 0 ? val0 : val1,elemType,params);
          }
 else {
            gen.appendExpression(val1,isSafeHtml,false,false);
          }
        }
        @Override public void visit(        StringChunk stringChunk){
          gen.appendStringLiteral(stringChunk.getString());
        }
      }
);
    }
  }
 catch (  ParseException e) {
    logger.log(TreeLogger.ERROR,"String_Node_Str" + listPattern + "String_Node_Str"+ locale,e);
    throw new UnableToCompleteException();
  }
  gen.completeString();
  return buf;
}