Program: 63297
Project: 63297
Buggy source:
/** 
 * INTERNAL:
 */
protected void writeValue(String value,boolean isAttribute,StringBuilder writer){
  CharacterEscapeHandler escapeHandler=null;
  if (marshaller != null) {
    escapeHandler=marshaller.getCharacterEscapeHandler();
  }
  if (escapeHandler != null) {
    try {
      StringWriter sw=new StringWriter();
      escapeHandler.escape(value.toCharArray(),0,value.length(),isAttribute,sw);
      writer.append(sw.toString());
    }
 catch (    IOException e) {
      throw XMLMarshalException.marshalException(e);
    }
    return;
  }
  if (null == encoder) {
    encoder=Constants.DEFAULT_CHARSET.newEncoder();
    charset=defaultCharset;
  }
  char[] chars=value.toCharArray();
  for (int x=0, charsSize=chars.length; x < charsSize; x++) {
    char character=chars[x];
switch (character) {
case '&':
{
        writer.append("String_Node_Str");
        break;
      }
case '<':
{
      writer.append("String_Node_Str");
      break;
    }
case '"':
{
    writer.append("String_Node_Str");
    break;
  }
case '\n':
{
  if (isAttribute) {
    writer.append("String_Node_Str");
  }
 else {
    writer.append('\n');
  }
  break;
}
case '\r':
{
writer.append("String_Node_Str");
break;
}
default :
if (charset == defaultCharset) {
writer.append(character);
}
 else {
if (encoder.canEncode(character)) {
writer.append(character);
}
 else {
writer.append("String_Node_Str");
writer.append(Integer.toString(character));
writer.append(';');
}
}
}
}
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
protected void writeValue(String value,boolean isAttribute,StringBuilder writer){
  CharacterEscapeHandler escapeHandler=null;
  if (marshaller != null) {
    escapeHandler=marshaller.getCharacterEscapeHandler();
  }
  if (escapeHandler != null) {
    try {
      StringWriter sw=new StringWriter();
      escapeHandler.escape(value.toCharArray(),0,value.length(),isAttribute,sw);
      writer.append(sw.toString());
    }
 catch (    IOException e) {
      throw XMLMarshalException.marshalException(e);
    }
    return;
  }
  if (null == encoder) {
    encoder=Constants.DEFAULT_CHARSET.newEncoder();
    charset=defaultCharset;
  }
  char[] chars=value.toCharArray();
  int nClosingSquareBracketsInRow=0;
  for (int x=0, charsSize=chars.length; x < charsSize; x++) {
    char character=chars[x];
switch (character) {
case '&':
{
        writer.append("String_Node_Str");
        break;
      }
case '<':
{
      writer.append("String_Node_Str");
      break;
    }
case '>':
{
    if (nClosingSquareBracketsInRow >= 2) {
      writer.append("String_Node_Str");
    }
 else {
      writer.append(character);
    }
    break;
  }
case '"':
{
  writer.append("String_Node_Str");
  break;
}
case '\n':
{
if (isAttribute) {
  writer.append("String_Node_Str");
}
 else {
  writer.append('\n');
}
break;
}
case '\r':
{
writer.append("String_Node_Str");
break;
}
default :
if (charset == defaultCharset) {
writer.append(character);
}
 else {
if (encoder.canEncode(character)) {
writer.append(character);
}
 else {
writer.append("String_Node_Str");
writer.append(Integer.toString(character));
writer.append(';');
}
}
}
if (!isAttribute) {
if (']' == character) {
++nClosingSquareBracketsInRow;
}
 else {
nClosingSquareBracketsInRow=0;
}
}
}
}