Program: 46847
Project: 46847
Buggy source:
/** 
 * reads an concrete type
 * @param in
 * @param type
 * @return
 * @throws IllegalArgumentException
 * @throws IllegalAccessException
 * @throws IOException
 * @throws InstantiationException
 * @throws ClassNotFoundException
 * @throws SecurityException
 * @throws NoSuchMethodException
 * @throws InvocationTargetException
 */
private Object read(final DataInputStream in,final byte type) throws IllegalArgumentException, IllegalAccessException, IOException, InstantiationException, ClassNotFoundException, SecurityException, InvocationTargetException {
switch (type) {
case nullEid:
    return null;
case boolTrueEid:
case pBoolTrueEid:
  return Boolean.TRUE;
case boolFalseEid:
case pBoolFalseEid:
return Boolean.FALSE;
case byteEid:
case pByteEid:
return Byte.valueOf(in.readByte());
case shortEid:
case pShortEid:
return Short.valueOf(in.readShort());
case intEid:
case pIntEid:
return Integer.valueOf(in.readInt());
case longEid:
case pLongEid:
return Long.valueOf(in.readLong());
case floatEid:
case pFloatEid:
return Float.valueOf(in.readFloat());
case doubleEid:
case pDoubleEid:
return Double.valueOf(in.readDouble());
case stringEid:
return in.readUTF();
case charEid:
case pCharEid:
return Character.valueOf(in.readUTF().charAt(0));
case objEid:
return new Object();
case arrayEid:
final byte atype=in.readByte();
final Class<?> comp=idxToClasses.get(atype);
if (comp == null) {
LOG.error("String_Node_Str" + atype + "String_Node_Str");
return null;
}
if (atype == nullEid) return null;
return readArray(in,atype,comp);
case -1:
throw new IllegalStateException("String_Node_Str");
default :
final Class<?> cl=idxToClasses.get(type);
if (cl == null) {
LOG.error("String_Node_Str" + type + "String_Node_Str");
return null;
}
 else if (cl.isEnum()) return cl.getEnumConstants()[in.readByte()];
 else {
Constructor<?> con;
try {
con=cl.getDeclaredConstructor();
}
 catch (final NoSuchMethodException e) {
throw new IllegalStateException("String_Node_Str" + cl.getTypeName() + "String_Node_Str");
}
if (!Modifier.isPublic(con.getModifiers())) con.setAccessible(true);
final Object target=con.newInstance();
final List<Field> fields=getFields(cl);
for (final Field field : fields) if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers())) {
if (field.getAnnotation(IgnoreRead.class) != null) continue;
if (!Modifier.isPublic(field.getModifiers())) field.setAccessible(true);
try {
field.set(target,read(in));
}
 catch (final IllegalStateException ex) {
LOG.error("String_Node_Str" + field + "String_Node_Str"+ ex.getMessage()+ "String_Node_Str");
throw ex;
}
}
return filter(target);
}
}
}

Fixed version (ground truth):
/** 
 * reads an concrete type
 * @param in
 * @param type
 * @return
 * @throws IllegalArgumentException
 * @throws IllegalAccessException
 * @throws IOException
 * @throws InstantiationException
 * @throws ClassNotFoundException
 * @throws SecurityException
 * @throws NoSuchMethodException
 * @throws InvocationTargetException
 */
private Object read(final DataInputStream in,final byte type) throws IllegalArgumentException, IllegalAccessException, IOException, InstantiationException, ClassNotFoundException, SecurityException, InvocationTargetException {
switch (type) {
case nullEid:
    return null;
case boolTrueEid:
case pBoolTrueEid:
  return Boolean.TRUE;
case boolFalseEid:
case pBoolFalseEid:
return Boolean.FALSE;
case byteEid:
case pByteEid:
return Byte.valueOf(in.readByte());
case shortEid:
case pShortEid:
return Short.valueOf(in.readShort());
case intEid:
case pIntEid:
return Integer.valueOf(in.readInt());
case longEid:
case pLongEid:
return Long.valueOf(in.readLong());
case floatEid:
case pFloatEid:
return Float.valueOf(in.readFloat());
case doubleEid:
case pDoubleEid:
return Double.valueOf(in.readDouble());
case stringEid:
return in.readUTF();
case charEid:
case pCharEid:
return Character.valueOf(in.readUTF().charAt(0));
case objEid:
return new Object();
case arrayEid:
final byte atype=in.readByte();
final short atypei=(short)(atype & 0xff);
final Class<?> comp=idxToClasses.get(atypei);
if (comp == null) {
LOG.error("String_Node_Str" + atypei + "String_Node_Str");
return null;
}
if (atype == nullEid) return null;
return readArray(in,atype,comp);
case -1:
throw new IllegalStateException("String_Node_Str");
default :
final short typei=(short)(type & 0xff);
final Class<?> cl=idxToClasses.get(typei);
if (cl == null) {
LOG.error("String_Node_Str" + typei + "String_Node_Str");
return null;
}
 else if (cl.isEnum()) return cl.getEnumConstants()[in.readByte()];
 else {
Constructor<?> con;
try {
con=cl.getDeclaredConstructor();
}
 catch (final NoSuchMethodException e) {
throw new IllegalStateException("String_Node_Str" + cl.getTypeName() + "String_Node_Str");
}
if (!Modifier.isPublic(con.getModifiers())) con.setAccessible(true);
final Object target=con.newInstance();
final List<Field> fields=getFields(cl);
for (final Field field : fields) if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers())) {
if (field.getAnnotation(IgnoreRead.class) != null) continue;
if (!Modifier.isPublic(field.getModifiers())) field.setAccessible(true);
try {
field.set(target,read(in));
}
 catch (final IllegalStateException ex) {
LOG.error("String_Node_Str" + field + "String_Node_Str"+ ex.getMessage()+ "String_Node_Str");
throw ex;
}
}
return filter(target);
}
}
}