Program: 56957
Project: 56957
Buggy source:
/** 
 * This methods generates the HTML code of the current b:message.
 * @param context the FacesContext.
 * @param component the current b:message.
 * @throws IOException thrown if something goes wrong when writing the HTML code.
 */
@Override public void encodeBegin(FacesContext context,UIComponent component) throws IOException {
  if (!component.isRendered()) {
    return;
  }
  Message message=(Message)component;
  String forValue=message.getFor();
  if (null == forValue || forValue.length() == 0)   forValue="String_Node_Str";
  forValue=ExpressionResolver.getComponentIDs(context,message,forValue);
  List<FacesMessage> messageList=new ArrayList<FacesMessage>();
  Iterator<FacesMessage> messageIterator=FacesContext.getCurrentInstance().getMessages(forValue);
  while (messageIterator.hasNext()) {
    FacesMessage fm=messageIterator.next();
    messageList.add(fm);
  }
  ResponseWriter rw=context.getResponseWriter();
  String clientId=message.getClientId();
  rw.startElement("String_Node_Str",message);
  writeAttribute(rw,"String_Node_Str",clientId);
  if (null != messageList && (!messageList.isEmpty())) {
    if (null != message.getDir()) {
      rw.writeAttribute("String_Node_Str",message.getDir(),"String_Node_Str");
    }
    String styleClass=message.getStyleClass();
    if (null != styleClass && styleClass.length() > 0)     styleClass=styleClass + "String_Node_Str";
 else     styleClass="String_Node_Str";
    String severityClass=findHighestSeverityClass(messageList,message);
    styleClass+="String_Node_Str" + severityClass + "String_Node_Str";
    styleClass+=Responsive.getResponsiveStyleClass(message,false);
    writeAttribute(rw,"String_Node_Str",styleClass.trim());
    writeAttribute(rw,"String_Node_Str",findHighestSeverityStyle(messageList,message));
    writeAttribute(rw,"String_Node_Str","String_Node_Str");
    boolean onlyMostSevere=message.isOnlyMostSevere();
    FacesMessage mostSevere=null;
    if (onlyMostSevere) {
      for (      FacesMessage msg : messageList) {
        if (null == mostSevere) {
          mostSevere=msg;
        }
 else         if (msg.getSeverity().getOrdinal() > mostSevere.getSeverity().getOrdinal()) {
          mostSevere=msg;
        }
      }
    }
    boolean firstMessage=true;
    for (    FacesMessage msg : messageList) {
      if (onlyMostSevere && msg != mostSevere) {
        continue;
      }
      if (!firstMessage) {
        if (message.isLineBreak()) {
          rw.append(message.getLineBreakTag());
        }
      }
      firstMessage=false;
      if (message.isShowIcon()) {
        rw.startElement("String_Node_Str",component);
        writeAttribute(rw,"String_Node_Str",findHighestSeverityIcon(messageList,message) + "String_Node_Str");
        writeAttribute(rw,"String_Node_Str","String_Node_Str");
        rw.endElement("String_Node_Str");
      }
      if (message.isShowSummary() && msg.getSummary() != null && !msg.getSummary().equals(msg.getDetail())) {
        rw.startElement("String_Node_Str",component);
        writeAttribute(rw,"String_Node_Str","String_Node_Str");
        if (message.isEscape()) {
          rw.writeText(msg.getSummary(),null);
        }
 else {
          warnOnFirstUse();
          rw.write(msg.getSummary());
        }
        rw.endElement("String_Node_Str");
      }
      if (message.isShowDetail() && msg.getDetail() != null) {
        rw.startElement("String_Node_Str",component);
        writeAttribute(rw,"String_Node_Str","String_Node_Str");
        if (message.isEscape()) {
          rw.writeText(msg.getDetail(),null);
        }
 else {
          warnOnFirstUse();
          rw.write(msg.getDetail());
        }
        rw.endElement("String_Node_Str");
      }
      msg.rendered();
    }
  }
  rw.endElement("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * This methods generates the HTML code of the current b:message.
 * @param context the FacesContext.
 * @param component the current b:message.
 * @throws IOException thrown if something goes wrong when writing the HTML code.
 */
@Override public void encodeBegin(FacesContext context,UIComponent component) throws IOException {
  if (!component.isRendered()) {
    return;
  }
  Message message=(Message)component;
  String forValue=message.getFor();
  if (null == forValue || forValue.length() == 0)   forValue="String_Node_Str";
  forValue=ExpressionResolver.getComponentIDs(context,message,forValue);
  List<FacesMessage> messageList=new ArrayList<FacesMessage>();
  Iterator<FacesMessage> messageIterator=FacesContext.getCurrentInstance().getMessages(forValue);
  while (messageIterator.hasNext()) {
    FacesMessage fm=messageIterator.next();
    messageList.add(fm);
  }
  ResponseWriter rw=context.getResponseWriter();
  String clientId=message.getClientId();
  rw.startElement("String_Node_Str",message);
  writeAttribute(rw,"String_Node_Str",clientId);
  if (null != messageList && (!messageList.isEmpty())) {
    if (null != message.getDir()) {
      rw.writeAttribute("String_Node_Str",message.getDir(),"String_Node_Str");
    }
    String styleClass=message.getStyleClass();
    if (null != styleClass && styleClass.length() > 0)     styleClass=styleClass + "String_Node_Str";
 else     styleClass="String_Node_Str";
    String severityClass=findHighestSeverityClass(messageList,message);
    styleClass+="String_Node_Str" + severityClass + "String_Node_Str";
    styleClass+=Responsive.getResponsiveStyleClass(message,false);
    writeAttribute(rw,"String_Node_Str",styleClass.trim());
    String style=message.getStyle();
    if (null == style)     style="String_Node_Str";
 else     if (!style.endsWith("String_Node_Str"))     style+="String_Node_Str";
    String severityStyle=findHighestSeverityStyle(messageList,message);
    if (null == severityStyle)     severityStyle="String_Node_Str";
 else     if (!severityStyle.endsWith("String_Node_Str"))     severityStyle+="String_Node_Str";
    writeAttribute(rw,"String_Node_Str",style + severityStyle);
    writeAttribute(rw,"String_Node_Str","String_Node_Str");
    boolean onlyMostSevere=message.isOnlyMostSevere();
    FacesMessage mostSevere=null;
    if (onlyMostSevere) {
      for (      FacesMessage msg : messageList) {
        if (null == mostSevere) {
          mostSevere=msg;
        }
 else         if (msg.getSeverity().getOrdinal() > mostSevere.getSeverity().getOrdinal()) {
          mostSevere=msg;
        }
      }
    }
    boolean firstMessage=true;
    for (    FacesMessage msg : messageList) {
      if (onlyMostSevere && msg != mostSevere) {
        continue;
      }
      if (!firstMessage) {
        if (message.isLineBreak()) {
          rw.append(message.getLineBreakTag());
        }
      }
      firstMessage=false;
      if (message.isShowIcon()) {
        rw.startElement("String_Node_Str",component);
        writeAttribute(rw,"String_Node_Str",findHighestSeverityIcon(messageList,message) + "String_Node_Str");
        writeAttribute(rw,"String_Node_Str","String_Node_Str");
        rw.endElement("String_Node_Str");
      }
      if (message.isShowSummary() && msg.getSummary() != null && !msg.getSummary().equals(msg.getDetail())) {
        rw.startElement("String_Node_Str",component);
        writeAttribute(rw,"String_Node_Str","String_Node_Str");
        if (message.isEscape()) {
          rw.writeText(msg.getSummary(),null);
        }
 else {
          warnOnFirstUse();
          rw.write(msg.getSummary());
        }
        rw.endElement("String_Node_Str");
      }
      if (message.isShowDetail() && msg.getDetail() != null) {
        rw.startElement("String_Node_Str",component);
        writeAttribute(rw,"String_Node_Str","String_Node_Str");
        if (message.isEscape()) {
          rw.writeText(msg.getDetail(),null);
        }
 else {
          warnOnFirstUse();
          rw.write(msg.getDetail());
        }
        rw.endElement("String_Node_Str");
      }
      msg.rendered();
    }
  }
  rw.endElement("String_Node_Str");
}