Program: 80193
Project: 80193
Buggy source:
private Object fromDBObject(final Schema fieldSchema,final DocumentFieldType storeType,final Field field,final String docf,final BSONDecorator easybson){
  Object result=null;
switch (fieldSchema.getType()) {
case MAP:
    BasicDBObject map=easybson.getDBObject(docf);
  StatefulHashMap<Utf8,Object> rmap=new StatefulHashMap<Utf8,Object>();
for (Entry<String,Object> e : map.entrySet()) {
  String oKey=e.getKey().replace("String_Node_Str","String_Node_Str");
switch (fieldSchema.getValueType().getType()) {
case STRING:
    rmap.put(new Utf8(oKey),new Utf8((String)e.getValue()));
  break;
case BYTES:
rmap.put(new Utf8(oKey),ByteBuffer.wrap((byte[])e.getValue()));
break;
default :
rmap.put(new Utf8(oKey),e.getValue());
break;
}
}
rmap.clearStates();
result=rmap;
break;
case ARRAY:
List<Object> list=easybson.getDBList(docf);
switch (fieldSchema.getElementType().getType()) {
case STRING:
ListGenericArray<Utf8> arrS=new ListGenericArray<Utf8>(fieldSchema);
for (Object o : list) arrS.add(new Utf8((String)o));
result=arrS;
break;
case BYTES:
ListGenericArray<ByteBuffer> arrB=new ListGenericArray<ByteBuffer>(fieldSchema);
for (Object o : list) arrB.add(ByteBuffer.wrap((byte[])o));
result=arrB;
break;
default :
ListGenericArray<Object> arrT=new ListGenericArray<Object>(fieldSchema);
for (Object o : list) arrT.add(o);
result=arrT;
break;
}
break;
case RECORD:
DBObject rec=easybson.getDBObject(docf);
BSONDecorator innerBson=new BSONDecorator(rec);
Class<?> clazz=null;
try {
clazz=ClassLoadingUtils.loadClass(fieldSchema.getFullName());
}
 catch (ClassNotFoundException e) {
}
Persistent record=new BeanFactoryImpl(keyClass,clazz).newPersistent();
for (Field recField : fieldSchema.getFields()) {
Schema innerSchema=recField.schema();
DocumentFieldType innerStoreType=mapping.getDocumentFieldType(innerSchema.getName());
String recDocField=mapping.getDocumentField(recField.name()) != null ? mapping.getDocumentField(recField.name()) : recField.name();
((PersistentBase)record).put(recField.pos(),fromDBObject(innerSchema,innerStoreType,recField,recDocField,innerBson));
}
result=record;
break;
case BOOLEAN:
result=easybson.getBoolean(docf);
break;
case DOUBLE:
result=easybson.getDouble(docf);
break;
case FLOAT:
result=easybson.getDouble(docf).floatValue();
break;
case INT:
result=easybson.getInt(docf);
break;
case LONG:
result=easybson.getLong(docf);
break;
case STRING:
if (storeType == DocumentFieldType.OBJECTID) {
final Object bin=easybson.get(docf);
final ObjectId id=ObjectId.massageToObjectId(bin);
result=new Utf8(id.toString());
}
 else if (storeType == DocumentFieldType.DATE) {
final Object bin=easybson.get(docf);
if (bin instanceof Date) {
Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("String_Node_Str"));
calendar.setTime((Date)bin);
result=new Utf8(DatatypeConverter.printDateTime(calendar));
}
 else {
result=new Utf8(bin.toString());
}
}
 else {
result=easybson.getUtf8String(docf);
}
break;
case ENUM:
result=AvroUtils.getEnumValue(fieldSchema,easybson.getUtf8String(docf).toString());
break;
case BYTES:
case FIXED:
result=easybson.getBytes(docf);
break;
case NULL:
result=null;
break;
case UNION:
Type type0=fieldSchema.getTypes().get(0).getType();
Type type1=fieldSchema.getTypes().get(1).getType();
if (!type0.equals(type1) && (type0.equals(Type.NULL) || type1.equals(Type.NULL))) {
Schema innerSchema=fieldSchema.getTypes().get(1);
DocumentFieldType innerStoreType=mapping.getDocumentFieldType(innerSchema.getName());
result=fromDBObject(innerSchema,innerStoreType,field,docf,easybson);
}
break;
default :
LOG.warn("String_Node_Str",docf);
break;
}
return result;
}

Fixed version (ground truth):
private Object fromDBObject(final Schema fieldSchema,final DocumentFieldType storeType,final Field field,final String docf,final BSONDecorator easybson){
  Object result=null;
switch (fieldSchema.getType()) {
case MAP:
    BasicDBObject map=easybson.getDBObject(docf);
  StatefulHashMap<Utf8,Object> rmap=new StatefulHashMap<Utf8,Object>();
for (Entry<String,Object> e : map.entrySet()) {
  String oKey=e.getKey().replace("String_Node_Str","String_Node_Str");
switch (fieldSchema.getValueType().getType()) {
case STRING:
    rmap.put(new Utf8(oKey),new Utf8((String)e.getValue()));
  break;
case BYTES:
rmap.put(new Utf8(oKey),ByteBuffer.wrap((byte[])e.getValue()));
break;
default :
rmap.put(new Utf8(oKey),e.getValue());
break;
}
}
rmap.clearStates();
result=rmap;
break;
case ARRAY:
List<Object> list=easybson.getDBList(docf);
switch (fieldSchema.getElementType().getType()) {
case STRING:
ListGenericArray<Utf8> arrS=new ListGenericArray<Utf8>(fieldSchema);
for (Object o : list) arrS.add(new Utf8((String)o));
result=arrS;
break;
case BYTES:
ListGenericArray<ByteBuffer> arrB=new ListGenericArray<ByteBuffer>(fieldSchema);
for (Object o : list) arrB.add(ByteBuffer.wrap((byte[])o));
result=arrB;
break;
default :
ListGenericArray<Object> arrT=new ListGenericArray<Object>(fieldSchema);
for (Object o : list) arrT.add(o);
result=arrT;
break;
}
break;
case RECORD:
DBObject rec=easybson.getDBObject(docf);
if (rec == null) {
return result;
}
BSONDecorator innerBson=new BSONDecorator(rec);
Class<?> clazz=null;
try {
clazz=ClassLoadingUtils.loadClass(fieldSchema.getFullName());
}
 catch (ClassNotFoundException e) {
}
Persistent record=new BeanFactoryImpl(keyClass,clazz).newPersistent();
for (Field recField : fieldSchema.getFields()) {
Schema innerSchema=recField.schema();
DocumentFieldType innerStoreType=mapping.getDocumentFieldType(innerSchema.getName());
String innerDocField=mapping.getDocumentField(recField.name()) != null ? mapping.getDocumentField(recField.name()) : recField.name();
String fieldPath=docf + "String_Node_Str" + innerDocField;
LOG.debug("String_Node_Str",new Object[]{recField.name(),innerSchema.getType(),fieldPath,innerStoreType});
((PersistentBase)record).put(recField.pos(),fromDBObject(innerSchema,innerStoreType,recField,innerDocField,innerBson));
}
result=record;
break;
case BOOLEAN:
result=easybson.getBoolean(docf);
break;
case DOUBLE:
result=easybson.getDouble(docf);
break;
case FLOAT:
result=easybson.getDouble(docf).floatValue();
break;
case INT:
result=easybson.getInt(docf);
break;
case LONG:
result=easybson.getLong(docf);
break;
case STRING:
if (storeType == DocumentFieldType.OBJECTID) {
final Object bin=easybson.get(docf);
final ObjectId id=ObjectId.massageToObjectId(bin);
result=new Utf8(id.toString());
}
 else if (storeType == DocumentFieldType.DATE) {
final Object bin=easybson.get(docf);
if (bin instanceof Date) {
Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("String_Node_Str"));
calendar.setTime((Date)bin);
result=new Utf8(DatatypeConverter.printDateTime(calendar));
}
 else {
result=new Utf8(bin.toString());
}
}
 else {
result=easybson.getUtf8String(docf);
}
break;
case ENUM:
result=AvroUtils.getEnumValue(fieldSchema,easybson.getUtf8String(docf).toString());
break;
case BYTES:
case FIXED:
result=easybson.getBytes(docf);
break;
case NULL:
result=null;
break;
case UNION:
Type type0=fieldSchema.getTypes().get(0).getType();
Type type1=fieldSchema.getTypes().get(1).getType();
if (!type0.equals(type1) && (type0.equals(Type.NULL) || type1.equals(Type.NULL))) {
Schema innerSchema=fieldSchema.getTypes().get(1);
DocumentFieldType innerStoreType=mapping.getDocumentFieldType(innerSchema.getName());
LOG.debug("String_Node_Str",new Object[]{innerSchema.getType(),docf,innerStoreType});
result=fromDBObject(innerSchema,innerStoreType,field,docf,easybson);
}
break;
default :
LOG.warn("String_Node_Str",docf);
break;
}
return result;
}