Program: 68012
Project: 68012
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);
        String sdoPath=convertXPathToSDOPath(nextXPath);
        nextCreatedDO=(SDODataObject)targetDataObject.getDataObject(sdoPath);
        if (nextCreatedDO == null) {
          int nextSlash=sdoPath.indexOf('/');
          if (nextSlash != -1) {
            sdoPath=sdoPath.substring(nextSlash + 1);
          }
 else {
            sdoPath="String_Node_Str";
          }
          nextCreatedDO=(SDODataObject)targetDataObject.getDataObject(sdoPath);
        }
        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=null;
      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();
        }
        String sdoPath=convertXPathToSDOPath(refValue);
        nextModifiedDO=(SDODataObject)targetDataObject.getDataObject(sdoPath);
        if (nextModifiedDO == null) {
          int nextSlash=sdoPath.indexOf('/');
          if (nextSlash != -1) {
            sdoPath=sdoPath.substring(nextSlash + 1);
          }
 else {
            sdoPath="String_Node_Str";
          }
          nextModifiedDO=(SDODataObject)targetDataObject.getDataObject(sdoPath);
        }
        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) {
                    String sdoRefPath=convertXPathToSDOPath(sdoRef);
                    int nextSlash=sdoRefPath.indexOf('/');
                    if (nextSlash != -1) {
                      sdoRefPath=sdoRefPath.substring(nextSlash + 1);
                    }
 else {
                      sdoRefPath="String_Node_Str";
                    }
                    newList.add(targetDataObject.getDataObject(sdoRefPath));
                  }
 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);
      boolean loggingValue=nextCS.isLoggingMapping();
      nextCS.setLogging(true);
      List xpaths=nextCS.getCreatedXPaths();
      String nextXPath=null;
      SDODataObject nextCreatedDO=null;
      for (int j=0; j < xpaths.size(); j++) {
        nextXPath=(String)xpaths.get(j);
        String sdoPath=convertXPathToSDOPath(nextXPath);
        nextCreatedDO=(SDODataObject)targetDataObject.getDataObject(sdoPath);
        if (nextCreatedDO == null) {
          int nextSlash=sdoPath.indexOf('/');
          if (nextSlash != -1) {
            sdoPath=sdoPath.substring(nextSlash + 1);
          }
 else {
            sdoPath="String_Node_Str";
          }
          nextCreatedDO=(SDODataObject)targetDataObject.getDataObject(sdoPath);
        }
        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=null;
      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();
        }
        String sdoPath=convertXPathToSDOPath(refValue);
        nextModifiedDO=(SDODataObject)targetDataObject.getDataObject(sdoPath);
        if (nextModifiedDO == null) {
          int nextSlash=sdoPath.indexOf('/');
          if (nextSlash != -1) {
            sdoPath=sdoPath.substring(nextSlash + 1);
          }
 else {
            sdoPath="String_Node_Str";
          }
          nextModifiedDO=(SDODataObject)targetDataObject.getDataObject(sdoPath);
        }
        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) {
                    String sdoRefPath=convertXPathToSDOPath(sdoRef);
                    int nextSlash=sdoRefPath.indexOf('/');
                    if (nextSlash != -1) {
                      sdoRefPath=sdoRefPath.substring(nextSlash + 1);
                    }
 else {
                      sdoRefPath="String_Node_Str";
                    }
                    newList.add(targetDataObject.getDataObject(sdoRefPath));
                  }
 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());
          }
        }
      }
      nextCS.setLogging(loggingValue);
    }
    initialize();
  }
}