Program: 8497
Project: 8497
Buggy source:
/** 
 * Create an entity with a specific ID or update an existing entity.
 * @param request
 * @param uriBuilder
 * @param repository
 * @param id
 * @return
 * @throws IOException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
@SuppressWarnings({"String_Node_Str"}) @RequestMapping(value="String_Node_Str",method={RequestMethod.PUT}) @ResponseBody public ResponseEntity<?> createOrUpdate(ServletServerHttpRequest request,UriComponentsBuilder uriBuilder,@PathVariable String repository,@PathVariable String id) throws IOException, IllegalAccessException, InstantiationException {
  URI baseUri=uriBuilder.build().toUri();
  RepositoryMetadata repoMeta=repositoryMetadataFor(repository);
  if (!repoMeta.exportsMethod(CrudMethod.SAVE_ONE) || !repoMeta.exportsMethod(CrudMethod.FIND_ONE)) {
    return negotiateResponse(request,HttpStatus.METHOD_NOT_ALLOWED,new HttpHeaders(),null);
  }
  Serializable serId=stringToSerializable(id,(Class<? extends Serializable>)repoMeta.entityMetadata().idAttribute().type());
  CrudRepository repo=repoMeta.repository();
  Class<?> domainType=repoMeta.entityMetadata().type();
  MediaType incomingMediaType=request.getHeaders().getContentType();
  Object incoming;
  if (null == (incoming=readIncoming(request,incomingMediaType,domainType))) {
    throw new HttpMessageNotReadableException("String_Node_Str" + domainType.getSimpleName() + "String_Node_Str");
  }
  repoMeta.entityMetadata().idAttribute().set(serId,incoming);
  boolean isUpdate=false;
  Object entity;
  if (null != (entity=repo.findOne(serId))) {
    isUpdate=true;
    for (    AttributeMetadata attrMeta : (Collection<AttributeMetadata>)repoMeta.entityMetadata().embeddedAttributes().values()) {
      Object incomingVal;
      if (null != (incomingVal=attrMeta.get(incoming))) {
        attrMeta.set(incomingVal,entity);
      }
    }
  }
 else {
    entity=incoming;
  }
  publishEvent(new BeforeSaveEvent(entity));
  Object savedEntity=repo.save(entity);
  publishEvent(new AfterSaveEvent(savedEntity));
  URI selfUri=buildUri(baseUri,repository,id);
  Object body=null;
  if (returnBody(request)) {
    MapResource res=createResource(repoMeta.rel(),savedEntity,repoMeta.entityMetadata(),baseUri);
    res.addLink(new SimpleLink(SELF,selfUri));
    publishEvent(new BeforeRenderResourceEvent(request,repoMeta,body));
    body=res;
  }
  if (!isUpdate) {
    HttpHeaders headers=new HttpHeaders();
    headers.set(LOCATION,selfUri.toString());
    return negotiateResponse(request,HttpStatus.CREATED,headers,body);
  }
 else {
    return negotiateResponse(request,(null != body ? HttpStatus.OK : HttpStatus.NO_CONTENT),new HttpHeaders(),body);
  }
}

Fixed version (ground truth):
/** 
 * Create an entity with a specific ID or update an existing entity.
 * @param request
 * @param uriBuilder
 * @param repository
 * @param id
 * @return
 * @throws IOException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
@SuppressWarnings({"String_Node_Str"}) @RequestMapping(value="String_Node_Str",method={RequestMethod.PUT}) @ResponseBody public ResponseEntity<?> createOrUpdate(ServletServerHttpRequest request,UriComponentsBuilder uriBuilder,@PathVariable String repository,@PathVariable String id) throws IOException, IllegalAccessException, InstantiationException {
  URI baseUri=uriBuilder.build().toUri();
  RepositoryMetadata repoMeta=repositoryMetadataFor(repository);
  if (!repoMeta.exportsMethod(CrudMethod.SAVE_ONE) || !repoMeta.exportsMethod(CrudMethod.FIND_ONE)) {
    return negotiateResponse(request,HttpStatus.METHOD_NOT_ALLOWED,new HttpHeaders(),null);
  }
  Serializable serId=stringToSerializable(id,(Class<? extends Serializable>)repoMeta.entityMetadata().idAttribute().type());
  CrudRepository repo=repoMeta.repository();
  Class<?> domainType=repoMeta.entityMetadata().type();
  MediaType incomingMediaType=request.getHeaders().getContentType();
  Object incoming;
  if (null == (incoming=readIncoming(request,incomingMediaType,domainType))) {
    throw new HttpMessageNotReadableException("String_Node_Str" + domainType.getSimpleName() + "String_Node_Str");
  }
  repoMeta.entityMetadata().idAttribute().set(serId,incoming);
  boolean isUpdate=false;
  Object entity;
  if (null != (entity=repo.findOne(serId))) {
    isUpdate=true;
    for (    AttributeMetadata attrMeta : (Collection<AttributeMetadata>)repoMeta.entityMetadata().embeddedAttributes().values()) {
      Object incomingVal;
      if (null != (incomingVal=attrMeta.get(incoming))) {
        attrMeta.set(incomingVal,entity);
      }
    }
  }
 else {
    entity=incoming;
  }
  publishEvent(new BeforeSaveEvent(entity));
  Object savedEntity=repo.save(entity);
  publishEvent(new AfterSaveEvent(savedEntity));
  URI selfUri=buildUri(baseUri,repository,id);
  Object body=null;
  if (returnBody(request)) {
    MapResource res=createResource(repoMeta.rel(),savedEntity,repoMeta.entityMetadata(),selfUri);
    res.addLink(new SimpleLink(SELF,selfUri));
    publishEvent(new BeforeRenderResourceEvent(request,repoMeta,body));
    body=res;
  }
  if (!isUpdate) {
    HttpHeaders headers=new HttpHeaders();
    headers.set(LOCATION,selfUri.toString());
    return negotiateResponse(request,HttpStatus.CREATED,headers,body);
  }
 else {
    return negotiateResponse(request,(null != body ? HttpStatus.OK : HttpStatus.NO_CONTENT),new HttpHeaders(),body);
  }
}