Program: 160617
Project: 160617
Buggy source:
private void writePrimitive(PrintWriter out,Object val) throws SerializerException {
  if (val instanceof Tristate) {
    Tristate bool=(Tristate)val;
    if (bool == Tristate.TRUE) {
      out.print(BOOLEAN_TRUE);
    }
 else     if (bool == Tristate.FALSE) {
      out.print(BOOLEAN_FALSE);
    }
 else     if (bool == Tristate.UNDEFINED) {
      out.print(BOOLEAN_UNDEFINED);
    }
  }
 else   if (val instanceof Double) {
    if (((Double)val).isInfinite() || (((Double)val).isNaN())) {
      LOGGER.info("String_Node_Str");
      out.print("String_Node_Str");
    }
 else {
      String string=val.toString();
      if (string.endsWith(DOT_0)) {
        out.print(string.substring(0,string.length() - 1));
      }
 else {
        out.print(string);
      }
    }
  }
 else   if (val instanceof Boolean) {
    Boolean bool=(Boolean)val;
    if (bool) {
      out.print(BOOLEAN_TRUE);
    }
 else {
      out.print(BOOLEAN_FALSE);
    }
  }
 else   if (val instanceof String) {
    out.print(SINGLE_QUOTE);
    String stringVal=(String)val;
    for (int i=0; i < stringVal.length(); i++) {
      char c=stringVal.charAt(i);
      if (c <= 126) {
        out.print(c);
      }
 else       if (c < 255) {
        out.write("String_Node_Str" + new String(Hex.encode(Charsets.ISO_8859_1.encode(CharBuffer.wrap(new char[]{(char)c})).array()),Charsets.UTF_8).toUpperCase());
      }
 else {
        if (useIso8859_1) {
          ByteBuffer encode=Charsets.ISO_8859_1.encode(new String(new char[]{(char)(c - 128)}));
          out.write("String_Node_Str" + (char)encode.get());
        }
 else {
          if (Character.isLowSurrogate(c)) {
            throw new SerializerException("String_Node_Str");
          }
 else           if (Character.isHighSurrogate(c)) {
            if (i + 1 < stringVal.length()) {
              char low=stringVal.charAt(i + 1);
              if (!Character.isLowSurrogate(low)) {
                throw new SerializerException("String_Node_Str");
              }
              try {
                out.write("String_Node_Str" + new String(Hex.encode(Charset.forName("String_Node_Str").encode(new String(new char[]{c,low})).array()),Charsets.UTF_8).toUpperCase() + "String_Node_Str");
              }
 catch (              UnsupportedCharsetException e) {
                throw new SerializerException(e);
              }
              i++;
            }
 else {
              throw new SerializerException("String_Node_Str");
            }
          }
 else {
            out.write("String_Node_Str" + new String(Hex.encode(Charsets.UTF_16.encode(CharBuffer.wrap(new char[]{c})).array()),Charsets.UTF_8).toUpperCase() + "String_Node_Str");
          }
        }
      }
    }
    out.print(SINGLE_QUOTE);
  }
 else   if (val instanceof Enumerator) {
    out.print("String_Node_Str" + val + "String_Node_Str");
  }
 else {
    out.print(val == null ? "String_Node_Str" : val.toString());
  }
}

Fixed version (ground truth):
private void writePrimitive(PrintWriter out,Object val) throws SerializerException {
  if (val instanceof Tristate) {
    Tristate bool=(Tristate)val;
    if (bool == Tristate.TRUE) {
      out.print(BOOLEAN_TRUE);
    }
 else     if (bool == Tristate.FALSE) {
      out.print(BOOLEAN_FALSE);
    }
 else     if (bool == Tristate.UNDEFINED) {
      out.print(BOOLEAN_UNDEFINED);
    }
  }
 else   if (val instanceof Double) {
    if (((Double)val).isInfinite() || (((Double)val).isNaN())) {
      LOGGER.info("String_Node_Str");
      out.print("String_Node_Str");
    }
 else {
      String string=val.toString();
      if (string.endsWith(DOT_0)) {
        out.print(string.substring(0,string.length() - 1));
      }
 else {
        out.print(string);
      }
    }
  }
 else   if (val instanceof Boolean) {
    Boolean bool=(Boolean)val;
    if (bool) {
      out.print(BOOLEAN_TRUE);
    }
 else {
      out.print(BOOLEAN_FALSE);
    }
  }
 else   if (val instanceof String) {
    out.print(SINGLE_QUOTE);
    String stringVal=(String)val;
    for (int i=0; i < stringVal.length(); i++) {
      char c=stringVal.charAt(i);
      if (c == '\'') {
        out.print("String_Node_Str");
      }
 else       if (c == '\\') {
        out.print("String_Node_Str");
      }
 else       if (c >= 32 && c <= 126) {
        out.print(c);
      }
 else       if (c < 255) {
        out.write("String_Node_Str" + new String(Hex.encode(Charsets.ISO_8859_1.encode(CharBuffer.wrap(new char[]{(char)c})).array()),Charsets.UTF_8).toUpperCase());
      }
 else {
        if (useIso8859_1) {
          ByteBuffer encode=Charsets.ISO_8859_1.encode(new String(new char[]{(char)(c - 128)}));
          out.write("String_Node_Str" + (char)encode.get());
        }
 else {
          if (Character.isLowSurrogate(c)) {
            throw new SerializerException("String_Node_Str");
          }
 else           if (Character.isHighSurrogate(c)) {
            if (i + 1 < stringVal.length()) {
              char low=stringVal.charAt(i + 1);
              if (!Character.isLowSurrogate(low)) {
                throw new SerializerException("String_Node_Str");
              }
              try {
                out.write("String_Node_Str" + new String(Hex.encode(Charset.forName("String_Node_Str").encode(new String(new char[]{c,low})).array()),Charsets.UTF_8).toUpperCase() + "String_Node_Str");
              }
 catch (              UnsupportedCharsetException e) {
                throw new SerializerException(e);
              }
              i++;
            }
 else {
              throw new SerializerException("String_Node_Str");
            }
          }
 else {
            out.write("String_Node_Str" + new String(Hex.encode(Charsets.UTF_16.encode(CharBuffer.wrap(new char[]{c})).array()),Charsets.UTF_8).toUpperCase() + "String_Node_Str");
          }
        }
      }
    }
    out.print(SINGLE_QUOTE);
  }
 else   if (val instanceof Enumerator) {
    out.print("String_Node_Str" + val + "String_Node_Str");
  }
 else {
    out.print(val == null ? "String_Node_Str" : val.toString());
  }
}