Program: 141458
Project: 141458
Buggy source:
/** 
 * Internal helper method to write the source object into the target document.
 * @param source the source object.
 * @param sink the target document.
 * @param entity the persistent entity to convert from.
 */
protected void writeInternal(final Object source,final CrateDocument sink,final CratePersistentEntity<?> entity){
  if (source == null) {
    return;
  }
  if (entity == null) {
    throw new MappingException("String_Node_Str".concat(source.getClass().getName()));
  }
  final BeanWrapper<Object> wrapper=create(source,conversionService);
  final CratePersistentProperty idProperty=entity.getIdProperty();
  final CratePersistentProperty versionProperty=entity.getVersionProperty();
  if (idProperty != null && !sink.containsKey(idProperty.getFieldName())) {
    try {
      Object id=convertToCrateType(wrapper.getProperty(idProperty,Object.class),idProperty.getTypeInformation());
      sink.put(idProperty.getFieldName(),id);
    }
 catch (    ConversionException e) {
      logger.warn("String_Node_Str",new Object[]{idProperty.getFieldName(),e.getMessage()});
    }
  }
  for (  CratePersistentProperty property : entity.getPersistentProperties()) {
    if (property.equals(idProperty) || (versionProperty != null && property.equals(versionProperty))) {
      continue;
    }
    Object propertyObj=wrapper.getProperty(property,property.getType());
    if (propertyObj != null) {
      if (!conversions.isSimpleType(propertyObj.getClass())) {
        writePropertyInternal(propertyObj,sink,property);
      }
 else {
        writeSimpleInternal(propertyObj,sink,property.getFieldName());
      }
    }
  }
  entity.doWithAssociations(new AssociationHandler<CratePersistentProperty>(){
    @Override public void doWithAssociation(    final Association<CratePersistentProperty> association){
      CratePersistentProperty inverse=association.getInverse();
      Class<?> type=inverse.getType();
      Object propertyObj=wrapper.getProperty(inverse,type);
      if (propertyObj != null) {
        writePropertyInternal(propertyObj,sink,inverse);
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Internal helper method to write the source object into the target document.
 * @param source the source object.
 * @param sink the target document.
 * @param entity the persistent entity to convert from.
 */
protected void writeInternal(final Object source,final CrateDocument sink,final CratePersistentEntity<?> entity){
  if (source == null) {
    return;
  }
  if (entity == null) {
    throw new MappingException("String_Node_Str".concat(source.getClass().getName()));
  }
  final BeanWrapper<Object> wrapper=create(source,conversionService);
  final CratePersistentProperty idProperty=entity.getIdProperty();
  final CratePersistentProperty versionProperty=entity.getVersionProperty();
  if (idProperty != null && !sink.containsKey(idProperty.getFieldName())) {
    try {
      Object id=convertToCrateType(wrapper.getProperty(idProperty,Object.class),idProperty.getTypeInformation());
      sink.put(idProperty.getFieldName(),id);
    }
 catch (    ConversionException e) {
      logger.warn("String_Node_Str",new Object[]{idProperty.getFieldName(),e.getMessage()});
    }
  }
  for (  CratePersistentProperty property : entity.getPersistentProperties()) {
    if (property.equals(idProperty) || (versionProperty != null && property.equals(versionProperty))) {
      continue;
    }
    Object propertyObj=wrapper.getProperty(property,property.getType());
    if (propertyObj != null) {
      if (!conversions.isSimpleType(propertyObj.getClass()) || isPrimitiveArray(property)) {
        writePropertyInternal(propertyObj,sink,property);
      }
 else {
        writeSimpleInternal(propertyObj,sink,property.getFieldName());
      }
    }
  }
  entity.doWithAssociations(new AssociationHandler<CratePersistentProperty>(){
    @Override public void doWithAssociation(    final Association<CratePersistentProperty> association){
      CratePersistentProperty inverse=association.getInverse();
      Class<?> type=inverse.getType();
      Object propertyObj=wrapper.getProperty(inverse,type);
      if (propertyObj != null) {
        writePropertyInternal(propertyObj,sink,inverse);
      }
    }
  }
);
}