Program: 68221
Project: 68221
Buggy source:
/** 
 * @param target assumed to be non-null
 * @param parent may be null, indicating target is root object
 */
public void afterUnmarshal(Object target,Object parent){
  SDODataObject targetDataObject;
  try {
    targetDataObject=(SDODataObject)target;
  }
 catch (  ClassCastException ccex) {
    ((SDOChangeSummary)target).setRootDataObject((DataObject)parent);
    changeSummaries.add(target);
    return;
  }
  if (targetDataObject.getType().isSequenced()) {
    ((SDOSequence)(targetDataObject.getSequence())).afterUnmarshal();
  }
  if (parent == null) {
    SDOChangeSummary nextCS=null;
    XMLUnmarshaller unmarshaller=((SDOXMLHelper)aHelperContext.getXMLHelper()).getXmlContext().createUnmarshaller();
    for (int i=0; i < changeSummaries.size(); i++) {
      nextCS=(SDOChangeSummary)changeSummaries.get(i);
      nextCS.setLogging(nextCS.isLoggingMapping());
      List xpaths=nextCS.getCreatedXPaths();
      String nextXPath=null;
      SDODataObject nextCreatedDO=null;
      for (int j=0; j < xpaths.size(); j++) {
        nextXPath=(String)xpaths.get(j);
        nextCreatedDO=(SDODataObject)targetDataObject.getDataObject(convertXPathToSDOPath(nextXPath));
        if (nextCreatedDO != null) {
          nextCreatedDO._setCreated(true);
          nextCS.getOldContainers().remove(nextCreatedDO);
        }
 else {
          throw SDOException.errorProcessingXPath(nextXPath);
        }
      }
      nextCS.setCreatedXPaths(null);
      List modifiedDoms=nextCS.getModifiedDoms();
      Element nextNode=null;
      String refValue=null;
      SDODataObject nextModifiedDO;
      for (int j=0; j < modifiedDoms.size(); j++) {
        nextNode=(Element)modifiedDoms.get(j);
        refValue=nextNode.getAttributeNS(SDOConstants.SDO_URL,SDOConstants.CHANGESUMMARY_REF);
        if ((refValue == null) || (refValue.length() == 0)) {
          throw SDOException.missingRefAttribute();
        }
        nextModifiedDO=(SDODataObject)targetDataObject.getDataObject(convertXPathToSDOPath(refValue));
        String unsetValue=nextNode.getAttributeNS(SDOConstants.SDO_URL,SDOConstants.CHANGESUMMARY_UNSET);
        List unsetValueList=new ArrayList();
        if ((unsetValue != null) && (unsetValue.length() > 0)) {
          XMLConversionManager xmlConversionManager=((SDOXMLHelper)aHelperContext.getXMLHelper()).getXmlConversionManager();
          unsetValueList=(List)xmlConversionManager.convertObject(unsetValue,List.class);
        }
        if (nextModifiedDO != null) {
          nextModifiedDO._setModified(true);
          SDOCSUnmarshalListener listener=new SDOCSUnmarshalListener(((SDOType)nextModifiedDO.getType()).getHelperContext(),true);
          unmarshaller.setUnmarshalListener(listener);
          unmarshaller.getProperties().put("String_Node_Str",aHelperContext);
          unmarshaller.setUnmappedContentHandlerClass(SDOUnmappedContentHandler.class);
          Object unmarshalledNode=unmarshaller.unmarshal(nextNode,((SDOType)nextModifiedDO.getType()).getXmlDescriptor().getJavaClass());
          DataObject unmarshalledDO=null;
          if (unmarshalledNode instanceof XMLRoot) {
            unmarshalledDO=(DataObject)((XMLRoot)unmarshalledNode).getObject();
          }
 else           if (unmarshalledNode instanceof DataObject) {
            unmarshalledDO=(DataObject)unmarshalledNode;
          }
          List modifiedProps=new ArrayList();
          NodeList children=nextNode.getChildNodes();
          for (int p=0; p < children.getLength(); p++) {
            Node n=children.item(p);
            if (n.getNodeType() == Node.ELEMENT_NODE) {
              String propName=n.getLocalName();
              Property nextProp=unmarshalledDO.getInstanceProperty(propName);
              if (nextProp == null) {
                nextProp=aHelperContext.getTypeHelper().getOpenContentProperty(n.getNamespaceURI(),propName);
              }
              if (!modifiedProps.contains(nextProp)) {
                modifiedProps.add(nextProp);
              }
            }
          }
          for (int k=0; k < modifiedProps.size(); k++) {
            SDOProperty nextProp=(SDOProperty)modifiedProps.get(k);
            if (!nextProp.getType().isDataType()) {
              if (nextProp.isMany()) {
                List originalValue=unmarshalledDO.getList(nextProp);
                List newList=new ArrayList();
                List toDelete=new ArrayList();
                List indexsToDelete=new ArrayList();
                for (int l=0; l < originalValue.size(); l++) {
                  SDODataObject nextInList=(SDODataObject)originalValue.get(l);
                  String sdoRef=nextInList._getSdoRef();
                  if (sdoRef != null) {
                    newList.add(targetDataObject.getDataObject(convertXPathToSDOPath(sdoRef)));
                  }
 else {
                    toDelete.add(nextInList);
                    indexsToDelete.add(new Integer(l));
                    newList.add(nextInList);
                  }
                }
                ListWrapper lw=((ListWrapper)nextModifiedDO.getList(nextProp));
                if (indexsToDelete.size() > 0) {
                  nextCS.pauseLogging();
                  for (int m=0; m < indexsToDelete.size(); m++) {
                    int toDeleteIndex=((Integer)indexsToDelete.get(m)).intValue();
                    SDODataObject nextToDelete=(SDODataObject)toDelete.get(m);
                    lw.add(toDeleteIndex,nextToDelete);
                  }
                  nextCS.setPropertyInternal(nextModifiedDO,nextProp,lw);
                  SDOSequence nextSeq=((SDOSequence)nextCS.getOriginalSequences().get(nextModifiedDO));
                  nextCS.resumeLogging();
                  nextModifiedDO._setModified(true);
                  for (int m=indexsToDelete.size() - 1; m >= 0; m--) {
                    int toDeleteIndex=((Integer)indexsToDelete.get(m)).intValue();
                    SDODataObject nextToDelete=(SDODataObject)toDelete.get(m);
                    if (nextSeq != null) {
                      nextSeq.addSettingWithoutModifyingDataObject(-1,nextProp,nextToDelete);
                    }
                    nextToDelete.resetChanges();
                    lw.remove(toDeleteIndex);
                  }
                }
                nextCS.getOriginalElements().put(lw,newList);
              }
 else {
                SDODataObject value=(SDODataObject)unmarshalledDO.getDataObject(nextProp);
                if (value != null) {
                  String sdoRef=value._getSdoRef();
                  if (sdoRef != null) {
                    nextModifiedDO._setModified(true);
                  }
 else {
                    value._setChangeSummary(nextCS);
                    nextModifiedDO._setModified(true);
                    nextCS.pauseLogging();
                    boolean wasSet=nextModifiedDO.isSet(nextProp);
                    Object existingValue=nextModifiedDO.get(nextProp);
                    Sequence nextModifiedDOSequence=nextModifiedDO.getSequence();
                    int settingIdx=-1;
                    if (nextModifiedDOSequence != null) {
                      settingIdx=((SDOSequence)nextModifiedDOSequence).getIndexForProperty(nextProp);
                    }
                    value._setContainmentPropertyName(null);
                    value._setContainer(null);
                    nextModifiedDO.set(nextProp,value);
                    nextCS.setPropertyInternal(nextModifiedDO,nextProp,value);
                    SDOSequence nextSeq=((SDOSequence)nextCS.getOriginalSequences().get(nextModifiedDO));
                    if (nextSeq != null) {
                      nextSeq.addSettingWithoutModifyingDataObject(-1,nextProp,value);
                    }
                    nextCS.resumeLogging();
                    nextModifiedDO._setModified(true);
                    value.resetChanges();
                    value.delete();
                    if (wasSet) {
                      nextModifiedDO.set(nextProp,existingValue,false);
                      if (settingIdx != -1) {
                        ((SDOSequence)nextModifiedDO.getSequence()).addSettingWithoutModifyingDataObject(settingIdx,nextProp,existingValue);
                      }
                    }
 else {
                      nextModifiedDO.unset(nextProp);
                    }
                  }
                }
 else {
                  nextModifiedDO._setModified(true);
                  nextCS.setPropertyInternal(nextModifiedDO,nextProp,null);
                }
              }
            }
 else {
              nextModifiedDO._setModified(true);
              Object value=unmarshalledDO.get(nextProp);
              if (nextProp.isMany()) {
                Property theProp=nextModifiedDO.getInstanceProperty(nextProp.getName());
                if (theProp == null) {
                  Property newProp=nextModifiedDO.defineOpenContentProperty(nextProp.getName(),new ArrayList(),nextProp.getType());
                  nextModifiedDO.set(newProp,new ArrayList());
                  theProp=newProp;
                }
                List lw=nextModifiedDO.getList(theProp.getName());
                nextCS.setPropertyInternal(nextModifiedDO,theProp,lw);
                nextCS.getOriginalElements().put(lw,((ListWrapper)value).getCurrentElements());
              }
 else {
                nextCS.setPropertyInternal(nextModifiedDO,nextProp,value);
              }
            }
          }
          for (int k=0; k < unsetValueList.size(); k++) {
            Property nextProp=unmarshalledDO.getInstanceProperty((String)unsetValueList.get(k));
            if (nextProp != null) {
              Object oldValue=null;
              if (nextProp.getType().isDataType() || nextProp.isMany()) {
                oldValue=unmarshalledDO.get(nextProp);
              }
              nextModifiedDO._setModified(true);
              nextCS.setPropertyInternal(nextModifiedDO,nextProp,oldValue);
              nextCS.unsetPropertyInternal(nextModifiedDO,nextProp);
            }
 else {
              nextProp=nextModifiedDO.getInstanceProperty((String)unsetValueList.get(k));
              nextModifiedDO._setModified(true);
              nextCS.setPropertyInternal(nextModifiedDO,nextProp,null);
              nextCS.unsetPropertyInternal(nextModifiedDO,nextProp);
            }
          }
        }
 else {
          throw SDOException.errorProcessingXPath(refValue);
        }
      }
      nextCS.setModifiedDoms(null);
      nextCS.setDeletedXPaths(null);
      Iterator created=nextCS.getCreated().iterator();
      while (created.hasNext()) {
        SDODataObject next=(SDODataObject)created.next();
        Property containmentProperty=next.getContainmentProperty();
        if (containmentProperty != null && containmentProperty.isMany()) {
          SDODataObject container=(SDODataObject)next.getContainer();
          ListWrapper list=(ListWrapper)container.get(containmentProperty);
          if (!(nextCS.getOriginalElements().containsKey(list))) {
            nextCS.getOriginalElements().put(list,new ArrayList());
          }
        }
      }
    }
    initialize();
  }
}

Fixed version (ground truth):
/** 
 * @param target assumed to be non-null
 * @param parent may be null, indicating target is root object
 */
public void afterUnmarshal(Object target,Object parent){
  SDODataObject targetDataObject;
  try {
    targetDataObject=(SDODataObject)target;
  }
 catch (  ClassCastException ccex) {
    ((SDOChangeSummary)target).setRootDataObject((DataObject)parent);
    changeSummaries.add(target);
    return;
  }
  if (targetDataObject.getType().isSequenced()) {
    ((SDOSequence)(targetDataObject.getSequence())).afterUnmarshal();
  }
  if (parent == null) {
    SDOChangeSummary nextCS=null;
    XMLUnmarshaller unmarshaller=((SDOXMLHelper)aHelperContext.getXMLHelper()).getXmlContext().createUnmarshaller();
    for (int i=0; i < changeSummaries.size(); i++) {
      nextCS=(SDOChangeSummary)changeSummaries.get(i);
      nextCS.setLogging(nextCS.isLoggingMapping());
      List xpaths=nextCS.getCreatedXPaths();
      String nextXPath=null;
      SDODataObject nextCreatedDO=null;
      for (int j=0; j < xpaths.size(); j++) {
        nextXPath=(String)xpaths.get(j);
        nextCreatedDO=(SDODataObject)targetDataObject.getDataObject(convertXPathToSDOPath(nextXPath));
        if (nextCreatedDO != null) {
          nextCreatedDO._setCreated(true);
          nextCS.getOldContainers().remove(nextCreatedDO);
        }
 else {
          throw SDOException.errorProcessingXPath(nextXPath);
        }
      }
      nextCS.setCreatedXPaths(null);
      List modifiedDoms=nextCS.getModifiedDoms();
      Element nextNode=null;
      String refValue=null;
      SDODataObject nextModifiedDO;
      for (int j=0; j < modifiedDoms.size(); j++) {
        nextNode=(Element)modifiedDoms.get(j);
        refValue=nextNode.getAttributeNS(SDOConstants.SDO_URL,SDOConstants.CHANGESUMMARY_REF);
        if ((refValue == null) || (refValue.length() == 0)) {
          throw SDOException.missingRefAttribute();
        }
        nextModifiedDO=(SDODataObject)targetDataObject.getDataObject(convertXPathToSDOPath(refValue));
        String unsetValue=nextNode.getAttributeNS(SDOConstants.SDO_URL,SDOConstants.CHANGESUMMARY_UNSET);
        List unsetValueList=new ArrayList();
        if ((unsetValue != null) && (unsetValue.length() > 0)) {
          XMLConversionManager xmlConversionManager=((SDOXMLHelper)aHelperContext.getXMLHelper()).getXmlConversionManager();
          unsetValueList=(List)xmlConversionManager.convertObject(unsetValue,List.class);
        }
        if (nextModifiedDO != null) {
          nextModifiedDO._setModified(true);
          SDOCSUnmarshalListener listener=new SDOCSUnmarshalListener(((SDOType)nextModifiedDO.getType()).getHelperContext(),true);
          unmarshaller.setUnmarshalListener(listener);
          unmarshaller.getProperties().put("String_Node_Str",aHelperContext);
          unmarshaller.setUnmappedContentHandlerClass(SDOUnmappedContentHandler.class);
          Object unmarshalledNode=unmarshaller.unmarshal(nextNode,((SDOType)nextModifiedDO.getType()).getXmlDescriptor().getJavaClass());
          DataObject unmarshalledDO=null;
          if (unmarshalledNode instanceof XMLRoot) {
            unmarshalledDO=(DataObject)((XMLRoot)unmarshalledNode).getObject();
          }
 else           if (unmarshalledNode instanceof DataObject) {
            unmarshalledDO=(DataObject)unmarshalledNode;
          }
          List modifiedProps=new ArrayList();
          Node n=nextNode.getFirstChild();
          while (n != null) {
            if (n.getNodeType() == Node.ELEMENT_NODE) {
              String propName=n.getLocalName();
              Property nextProp=unmarshalledDO.getInstanceProperty(propName);
              if (nextProp == null) {
                nextProp=aHelperContext.getTypeHelper().getOpenContentProperty(n.getNamespaceURI(),propName);
              }
              if (!modifiedProps.contains(nextProp)) {
                modifiedProps.add(nextProp);
              }
            }
            n=n.getNextSibling();
          }
          for (int k=0; k < modifiedProps.size(); k++) {
            SDOProperty nextProp=(SDOProperty)modifiedProps.get(k);
            if (!nextProp.getType().isDataType()) {
              if (nextProp.isMany()) {
                List originalValue=unmarshalledDO.getList(nextProp);
                List newList=new ArrayList();
                List toDelete=new ArrayList();
                List indexsToDelete=new ArrayList();
                for (int l=0; l < originalValue.size(); l++) {
                  SDODataObject nextInList=(SDODataObject)originalValue.get(l);
                  String sdoRef=nextInList._getSdoRef();
                  if (sdoRef != null) {
                    newList.add(targetDataObject.getDataObject(convertXPathToSDOPath(sdoRef)));
                  }
 else {
                    toDelete.add(nextInList);
                    indexsToDelete.add(new Integer(l));
                    newList.add(nextInList);
                  }
                }
                ListWrapper lw=((ListWrapper)nextModifiedDO.getList(nextProp));
                if (indexsToDelete.size() > 0) {
                  nextCS.pauseLogging();
                  for (int m=0; m < indexsToDelete.size(); m++) {
                    int toDeleteIndex=((Integer)indexsToDelete.get(m)).intValue();
                    SDODataObject nextToDelete=(SDODataObject)toDelete.get(m);
                    lw.add(toDeleteIndex,nextToDelete);
                  }
                  nextCS.setPropertyInternal(nextModifiedDO,nextProp,lw);
                  SDOSequence nextSeq=((SDOSequence)nextCS.getOriginalSequences().get(nextModifiedDO));
                  nextCS.resumeLogging();
                  nextModifiedDO._setModified(true);
                  for (int m=indexsToDelete.size() - 1; m >= 0; m--) {
                    int toDeleteIndex=((Integer)indexsToDelete.get(m)).intValue();
                    SDODataObject nextToDelete=(SDODataObject)toDelete.get(m);
                    if (nextSeq != null) {
                      nextSeq.addSettingWithoutModifyingDataObject(-1,nextProp,nextToDelete);
                    }
                    nextToDelete.resetChanges();
                    lw.remove(toDeleteIndex);
                  }
                }
                nextCS.getOriginalElements().put(lw,newList);
              }
 else {
                SDODataObject value=(SDODataObject)unmarshalledDO.getDataObject(nextProp);
                if (value != null) {
                  String sdoRef=value._getSdoRef();
                  if (sdoRef != null) {
                    nextModifiedDO._setModified(true);
                  }
 else {
                    value._setChangeSummary(nextCS);
                    nextModifiedDO._setModified(true);
                    nextCS.pauseLogging();
                    boolean wasSet=nextModifiedDO.isSet(nextProp);
                    Object existingValue=nextModifiedDO.get(nextProp);
                    Sequence nextModifiedDOSequence=nextModifiedDO.getSequence();
                    int settingIdx=-1;
                    if (nextModifiedDOSequence != null) {
                      settingIdx=((SDOSequence)nextModifiedDOSequence).getIndexForProperty(nextProp);
                    }
                    value._setContainmentPropertyName(null);
                    value._setContainer(null);
                    nextModifiedDO.set(nextProp,value);
                    nextCS.setPropertyInternal(nextModifiedDO,nextProp,value);
                    SDOSequence nextSeq=((SDOSequence)nextCS.getOriginalSequences().get(nextModifiedDO));
                    if (nextSeq != null) {
                      nextSeq.addSettingWithoutModifyingDataObject(-1,nextProp,value);
                    }
                    nextCS.resumeLogging();
                    nextModifiedDO._setModified(true);
                    value.resetChanges();
                    value.delete();
                    if (wasSet) {
                      nextModifiedDO.set(nextProp,existingValue,false);
                      if (settingIdx != -1) {
                        ((SDOSequence)nextModifiedDO.getSequence()).addSettingWithoutModifyingDataObject(settingIdx,nextProp,existingValue);
                      }
                    }
 else {
                      nextModifiedDO.unset(nextProp);
                    }
                  }
                }
 else {
                  nextModifiedDO._setModified(true);
                  nextCS.setPropertyInternal(nextModifiedDO,nextProp,null);
                }
              }
            }
 else {
              nextModifiedDO._setModified(true);
              Object value=unmarshalledDO.get(nextProp);
              if (nextProp.isMany()) {
                Property theProp=nextModifiedDO.getInstanceProperty(nextProp.getName());
                if (theProp == null) {
                  Property newProp=nextModifiedDO.defineOpenContentProperty(nextProp.getName(),new ArrayList(),nextProp.getType());
                  nextModifiedDO.set(newProp,new ArrayList());
                  theProp=newProp;
                }
                List lw=nextModifiedDO.getList(theProp.getName());
                nextCS.setPropertyInternal(nextModifiedDO,theProp,lw);
                nextCS.getOriginalElements().put(lw,((ListWrapper)value).getCurrentElements());
              }
 else {
                nextCS.setPropertyInternal(nextModifiedDO,nextProp,value);
              }
            }
          }
          for (int k=0; k < unsetValueList.size(); k++) {
            Property nextProp=unmarshalledDO.getInstanceProperty((String)unsetValueList.get(k));
            if (nextProp != null) {
              Object oldValue=null;
              if (nextProp.getType().isDataType() || nextProp.isMany()) {
                oldValue=unmarshalledDO.get(nextProp);
              }
              nextModifiedDO._setModified(true);
              nextCS.setPropertyInternal(nextModifiedDO,nextProp,oldValue);
              nextCS.unsetPropertyInternal(nextModifiedDO,nextProp);
            }
 else {
              nextProp=nextModifiedDO.getInstanceProperty((String)unsetValueList.get(k));
              nextModifiedDO._setModified(true);
              nextCS.setPropertyInternal(nextModifiedDO,nextProp,null);
              nextCS.unsetPropertyInternal(nextModifiedDO,nextProp);
            }
          }
        }
 else {
          throw SDOException.errorProcessingXPath(refValue);
        }
      }
      nextCS.setModifiedDoms(null);
      nextCS.setDeletedXPaths(null);
      Iterator created=nextCS.getCreated().iterator();
      while (created.hasNext()) {
        SDODataObject next=(SDODataObject)created.next();
        Property containmentProperty=next.getContainmentProperty();
        if (containmentProperty != null && containmentProperty.isMany()) {
          SDODataObject container=(SDODataObject)next.getContainer();
          ListWrapper list=(ListWrapper)container.get(containmentProperty);
          if (!(nextCS.getOriginalElements().containsKey(list))) {
            nextCS.getOriginalElements().put(list,new ArrayList());
          }
        }
      }
    }
    initialize();
  }
}