Program: 21662
Project: 21662
Buggy source:
/** 
 * FIXME:  This method uses the state database to determine whether an object can be directly changed or it needs to be wrapped by  a template (user object) and just that object is changed.  This should not be dependent on the state database because in some cases there will not be a separate database just for the state  objects.  So in this case there should be another way to know if an object should be directly changed when it is access through this database.  The reference map should probably be used for  this.
 * @see org.concord.otrunk.datamodel.OTDatabase#getOTDataObject(org.concord.otrunk.datamodel.OTDataObject,org.concord.framework.otrunk.OTID)
 */
public OTDataObject getOTDataObject(OTDataObject dataParent,OTID childId) throws Exception {
  if (childId instanceof OTRelativeID) {
    OTID childRootId=((OTRelativeID)childId).getRootId();
    if (childRootId.equals(getDatabaseId()))     childId=((OTRelativeID)childId).getRelativeId();
  }
  OTUserDataObject userDataObject=(OTUserDataObject)userDataObjectMap.get(childId);
  if (userDataObject != null) {
    return userDataObject;
  }
  userDataObject=(OTUserDataObject)mappedIdCache.get(childId);
  if (userDataObject != null) {
    return userDataObject;
  }
  if (stateDb.contains(childId)) {
    userDataObject=new OTUserDataObject(null,this);
    OTDataObject childObject=stateDb.getOTDataObject(null,childId);
    userDataObject.setStateObject(childObject);
    return userDataObject;
  }
  OTDataObject templateObject=rootDb.getOTDataObject(null,childId);
  if (templateObject == null) {
    System.err.println("String_Node_Str" + childId);
    return null;
  }
  userDataObject=new OTUserDataObject(templateObject,this);
  mappedIdCache.put(childId,userDataObject);
  userDataObjectMap.put(userDataObject.getGlobalId(),userDataObject);
  return userDataObject;
}

Fixed version (ground truth):
/** 
 * FIXME:  This method uses the state database to determine whether an object can be directly changed or it needs to be wrapped by  a template (user object) and just that object is changed.  This should not be dependent on the state database because in some cases there will not be a separate database just for the state  objects.  So in this case there should be another way to know if an object should be directly changed when it is access through this database.  The reference map should probably be used for  this.
 * @see org.concord.otrunk.datamodel.OTDatabase#getOTDataObject(org.concord.otrunk.datamodel.OTDataObject,org.concord.framework.otrunk.OTID)
 */
public OTDataObject getOTDataObject(OTDataObject dataParent,OTID childId) throws Exception {
  if (childId instanceof OTRelativeID) {
    OTID childRootId=((OTRelativeID)childId).getRootId();
    if (childRootId.equals(getDatabaseId()))     childId=((OTRelativeID)childId).getRelativeId();
  }
  OTUserDataObject userDataObject=(OTUserDataObject)userDataObjectMap.get(childId);
  if (userDataObject != null) {
    return userDataObject;
  }
  userDataObject=(OTUserDataObject)mappedIdCache.get(childId);
  if (userDataObject != null) {
    return userDataObject;
  }
  if (stateDb.contains(childId)) {
    userDataObject=new OTUserDataObject(null,this);
    OTDataObject childObject=stateDb.getOTDataObject(null,childId);
    userDataObject.setStateObject(childObject);
    mappedIdCache.put(childId,userDataObject);
    return userDataObject;
  }
  OTDataObject templateObject=rootDb.getOTDataObject(null,childId);
  if (templateObject == null) {
    System.err.println("String_Node_Str" + childId);
    return null;
  }
  userDataObject=new OTUserDataObject(templateObject,this);
  mappedIdCache.put(childId,userDataObject);
  userDataObjectMap.put(userDataObject.getGlobalId(),userDataObject);
  return userDataObject;
}