Program: 53305
Project: 53305
Buggy source:
/** 
 * Reserved for internal use.
 * @param buff
 * @param type
 * @param value
 */
public static void setData(java.nio.ByteBuffer buff,DataType type,Object value) throws RuntimeException, UnsupportedEncodingException, ParseException {
  if (value != null && type == DataType.NONE) {
    type=getValueType(value);
  }
  if (value instanceof Enum) {
    throw new RuntimeException("String_Node_Str");
  }
  if (type == DataType.DATETIME || type == DataType.DATE || type == DataType.TIME) {
    buff.put((byte)DataType.OCTET_STRING.getValue());
  }
 else   if ((type == DataType.ARRAY && value instanceof byte[])) {
    buff.put((byte[])value);
    return;
  }
 else {
    buff.put((byte)type.getValue());
  }
  if (type == DataType.NONE) {
    return;
  }
  if (type == DataType.BOOLEAN) {
    if (Boolean.parseBoolean(value.toString())) {
      buff.put((byte)1);
    }
 else {
      buff.put((byte)0);
    }
  }
 else   if (type == DataType.INT8 || type == DataType.UINT8 || type == DataType.ENUM) {
    buff.put(((Number)value).byteValue());
  }
 else   if (type == DataType.INT16 || type == DataType.UINT16) {
    buff.putShort(((Number)value).shortValue());
  }
 else   if (type == DataType.INT32 || type == DataType.UINT32) {
    buff.putInt(((Number)value).intValue());
  }
 else   if (type == DataType.INT64 || type == DataType.UINT64) {
    buff.putLong(((Number)value).longValue());
  }
 else   if (type == DataType.FLOAT32) {
    buff.putFloat(((Number)value).floatValue());
  }
 else   if (type == DataType.FLOAT64) {
    buff.putDouble(((Number)value).doubleValue());
  }
 else   if (type == DataType.BITSTRING) {
    throw new RuntimeException("String_Node_Str");
  }
 else   if (type == DataType.STRING) {
    if (value != null) {
      String str=value.toString();
      setObjectCount(str.length(),buff);
      buff.put(str.getBytes("String_Node_Str"));
    }
 else {
      setObjectCount(0,buff);
    }
  }
 else   if (type == DataType.OCTET_STRING) {
    if (value instanceof String) {
      String[] items=((String)value).split("String_Node_Str",-1);
      setObjectCount(items.length,buff);
      for (      String it : items) {
        buff.put((byte)Integer.parseInt(it));
      }
    }
 else     if (value instanceof byte[]) {
      setObjectCount(((byte[])value).length,buff);
      buff.put((byte[])value);
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
  }
 else   if (type == DataType.ARRAY || type == DataType.STRUCTURE) {
    if (value != null) {
      int len=Array.getLength(value);
      setObjectCount(len,buff);
      for (int pos=0; pos != len; ++pos) {
        Object it=Array.get(value,pos);
        setData(buff,getValueType(it),it);
      }
    }
 else {
      setObjectCount(0,buff);
    }
  }
 else   if (type == DataType.BCD) {
    if (!(value instanceof String)) {
      throw new RuntimeException("String_Node_Str");
    }
    String str=value.toString().trim();
    int len=str.length();
    if (len % 2 != 0) {
      str="String_Node_Str" + str;
      ++len;
    }
    len/=2;
    buff.put((byte)(len));
    for (int pos=0; pos != len; ++pos) {
      int ch1=Integer.parseInt(str.substring(2 * pos,2 * pos + 1));
      int ch2=Integer.parseInt(str.substring(2 * pos + 1,2 * pos + 1 + 1));
      buff.put((byte)(ch1 << 4 | ch2));
    }
  }
 else   if (type == DataType.COMPACTARRAY) {
    throw new RuntimeException("String_Node_Str");
  }
 else   if (type == DataType.DATETIME) {
    java.util.Calendar tm=java.util.Calendar.getInstance();
    if (value instanceof java.util.Date) {
      tm.setTime((java.util.Date)value);
    }
 else     if (value instanceof java.util.Calendar) {
      tm.setTime(((java.util.Calendar)value).getTime());
    }
 else     if (value instanceof String) {
      DateFormat f=new SimpleDateFormat();
      try {
        tm.setTime(f.parse(value.toString()));
      }
 catch (      ParseException ex) {
        throw new RuntimeException("String_Node_Str" + ex.getMessage());
      }
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
    buff.put((byte)12);
    buff.putShort((short)tm.get(java.util.Calendar.YEAR));
    buff.put((byte)(tm.get(java.util.Calendar.MONTH) + 1));
    buff.put((byte)tm.get(java.util.Calendar.DATE));
    buff.put((byte)0xFF);
    buff.put((byte)tm.get(java.util.Calendar.HOUR_OF_DAY));
    buff.put((byte)tm.get(java.util.Calendar.MINUTE));
    buff.put((byte)tm.get(java.util.Calendar.SECOND));
    buff.put((byte)0xFF);
    buff.put((byte)0x80);
    buff.put((byte)0x00);
    buff.put((byte)0xFF);
  }
 else   if (type == DataType.DATE) {
    java.util.Calendar tm=java.util.Calendar.getInstance();
    if (value instanceof java.util.Date) {
      tm.setTime((java.util.Date)value);
    }
 else     if (value instanceof java.util.Calendar) {
      tm.setTime(((java.util.Calendar)value).getTime());
    }
 else     if (value instanceof String) {
      DateFormat f=new SimpleDateFormat();
      tm.setTime(f.parse(value.toString()));
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
    buff.put((byte)5);
    buff.putShort((short)tm.get(java.util.Calendar.YEAR));
    buff.put((byte)(tm.get(java.util.Calendar.MONTH) + 1));
    buff.put((byte)tm.get(java.util.Calendar.DATE));
    buff.put((byte)0xFF);
  }
 else   if (type == DataType.TIME) {
    java.util.Calendar tm=java.util.Calendar.getInstance();
    if (value instanceof java.util.Date) {
      tm.setTime((java.util.Date)value);
    }
 else     if (value instanceof java.util.Calendar) {
      tm.setTime(((java.util.Calendar)value).getTime());
    }
 else     if (value instanceof String) {
      DateFormat f=new SimpleDateFormat();
      try {
        tm.setTime(f.parse(value.toString()));
      }
 catch (      ParseException ex) {
        throw new RuntimeException("String_Node_Str" + ex.getMessage());
      }
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
    buff.put((byte)7);
    buff.put((byte)tm.get(java.util.Calendar.HOUR_OF_DAY));
    buff.put((byte)tm.get(java.util.Calendar.MINUTE));
    buff.put((byte)tm.get(java.util.Calendar.SECOND));
    buff.put((byte)0xFF);
    buff.put((byte)0x80);
    buff.put((byte)0x00);
    buff.put((byte)0xFF);
  }
 else {
    throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Reserved for internal use.
 * @param buff
 * @param type
 * @param value
 */
public static void setData(java.nio.ByteBuffer buff,DataType type,Object value) throws RuntimeException, UnsupportedEncodingException, ParseException {
  if (value != null && type == DataType.NONE) {
    type=getValueType(value);
  }
  if (value instanceof Enum) {
    throw new RuntimeException("String_Node_Str");
  }
  if (type == DataType.DATETIME || type == DataType.DATE || type == DataType.TIME) {
    buff.put((byte)DataType.OCTET_STRING.getValue());
  }
 else   if ((type == DataType.ARRAY && value instanceof byte[])) {
    buff.put((byte[])value);
    return;
  }
 else {
    buff.put((byte)type.getValue());
  }
  if (type == DataType.NONE) {
    return;
  }
  if (type == DataType.BOOLEAN) {
    if (Boolean.parseBoolean(value.toString())) {
      buff.put((byte)1);
    }
 else {
      buff.put((byte)0);
    }
  }
 else   if (type == DataType.INT8 || type == DataType.UINT8 || type == DataType.ENUM) {
    buff.put(((Number)value).byteValue());
  }
 else   if (type == DataType.INT16 || type == DataType.UINT16) {
    buff.putShort(((Number)value).shortValue());
  }
 else   if (type == DataType.INT32 || type == DataType.UINT32) {
    buff.putInt(((Number)value).intValue());
  }
 else   if (type == DataType.INT64 || type == DataType.UINT64) {
    buff.putLong(((Number)value).longValue());
  }
 else   if (type == DataType.FLOAT32) {
    buff.putFloat(((Number)value).floatValue());
  }
 else   if (type == DataType.FLOAT64) {
    buff.putDouble(((Number)value).doubleValue());
  }
 else   if (type == DataType.BITSTRING) {
    throw new RuntimeException("String_Node_Str");
  }
 else   if (type == DataType.STRING) {
    if (value != null) {
      String str=value.toString();
      setObjectCount(str.length(),buff);
      buff.put(str.getBytes("String_Node_Str"));
    }
 else {
      setObjectCount(0,buff);
    }
  }
 else   if (type == DataType.OCTET_STRING) {
    if (value instanceof String) {
      String[] items=((String)value).split("String_Node_Str",-1);
      setObjectCount(items.length,buff);
      for (      String it : items) {
        buff.put((byte)Integer.parseInt(it));
      }
    }
 else     if (value instanceof byte[]) {
      setObjectCount(((byte[])value).length,buff);
      buff.put((byte[])value);
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
  }
 else   if (type == DataType.ARRAY || type == DataType.STRUCTURE) {
    if (value != null) {
      int len=Array.getLength(value);
      setObjectCount(len,buff);
      for (int pos=0; pos != len; ++pos) {
        Object it=Array.get(value,pos);
        setData(buff,getValueType(it),it);
      }
    }
 else {
      setObjectCount(0,buff);
    }
  }
 else   if (type == DataType.BCD) {
    if (!(value instanceof String)) {
      throw new RuntimeException("String_Node_Str");
    }
    String str=value.toString().trim();
    int len=str.length();
    if (len % 2 != 0) {
      str="String_Node_Str" + str;
      ++len;
    }
    len/=2;
    buff.put((byte)(len));
    for (int pos=0; pos != len; ++pos) {
      int ch1=Integer.parseInt(str.substring(2 * pos,2 * pos + 1));
      int ch2=Integer.parseInt(str.substring(2 * pos + 1,2 * pos + 1 + 1));
      buff.put((byte)(ch1 << 4 | ch2));
    }
  }
 else   if (type == DataType.COMPACTARRAY) {
    throw new RuntimeException("String_Node_Str");
  }
 else   if (type == DataType.DATETIME) {
    java.util.Calendar tm=java.util.Calendar.getInstance(java.util.TimeZone.getTimeZone("String_Node_Str"));
    if (value instanceof java.util.Date) {
      tm.setTime((java.util.Date)value);
    }
 else     if (value instanceof java.util.Calendar) {
      tm.setTime(((java.util.Calendar)value).getTime());
    }
 else     if (value instanceof String) {
      DateFormat f=new SimpleDateFormat();
      try {
        tm.setTime(f.parse(value.toString()));
      }
 catch (      ParseException ex) {
        throw new RuntimeException("String_Node_Str" + ex.getMessage());
      }
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
    buff.put((byte)12);
    buff.putShort((short)tm.get(java.util.Calendar.YEAR));
    buff.put((byte)(tm.get(java.util.Calendar.MONTH) + 1));
    buff.put((byte)tm.get(java.util.Calendar.DATE));
    buff.put((byte)0xFF);
    buff.put((byte)tm.get(java.util.Calendar.HOUR_OF_DAY));
    buff.put((byte)tm.get(java.util.Calendar.MINUTE));
    buff.put((byte)tm.get(java.util.Calendar.SECOND));
    buff.put((byte)0xFF);
    buff.put((byte)0x80);
    buff.put((byte)0x00);
    buff.put((byte)0xFF);
  }
 else   if (type == DataType.DATE) {
    java.util.Calendar tm=java.util.Calendar.getInstance(java.util.TimeZone.getTimeZone("String_Node_Str"));
    if (value instanceof java.util.Date) {
      tm.setTime((java.util.Date)value);
    }
 else     if (value instanceof java.util.Calendar) {
      tm.setTime(((java.util.Calendar)value).getTime());
    }
 else     if (value instanceof String) {
      DateFormat f=new SimpleDateFormat();
      tm.setTime(f.parse(value.toString()));
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
    buff.put((byte)5);
    buff.putShort((short)tm.get(java.util.Calendar.YEAR));
    buff.put((byte)(tm.get(java.util.Calendar.MONTH) + 1));
    buff.put((byte)tm.get(java.util.Calendar.DATE));
    buff.put((byte)0xFF);
  }
 else   if (type == DataType.TIME) {
    java.util.Calendar tm=java.util.Calendar.getInstance(java.util.TimeZone.getTimeZone("String_Node_Str"));
    if (value instanceof java.util.Date) {
      tm.setTime((java.util.Date)value);
    }
 else     if (value instanceof java.util.Calendar) {
      tm.setTime(((java.util.Calendar)value).getTime());
    }
 else     if (value instanceof String) {
      DateFormat f=new SimpleDateFormat();
      try {
        tm.setTime(f.parse(value.toString()));
      }
 catch (      ParseException ex) {
        throw new RuntimeException("String_Node_Str" + ex.getMessage());
      }
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
    buff.put((byte)7);
    buff.put((byte)tm.get(java.util.Calendar.HOUR_OF_DAY));
    buff.put((byte)tm.get(java.util.Calendar.MINUTE));
    buff.put((byte)tm.get(java.util.Calendar.SECOND));
    buff.put((byte)0xFF);
    buff.put((byte)0x80);
    buff.put((byte)0x00);
    buff.put((byte)0xFF);
  }
 else {
    throw new RuntimeException("String_Node_Str");
  }
}