Program: 63091
Project: 63091
Buggy source:
private void actionAcceptRecommendation(AnnotationActionHandler aActionHandler,AnnotatorState aState,AjaxRequestTarget aTarget,JCas aJCas,VID aVID,int aBegin,int aEnd) throws AnnotationException, IOException {
  Predictions model=recommendationService.getPredictions(aState.getUser(),aState.getProject());
  AnnotationObject prediction=model.getPredictionByVID(aVID);
  String predictedValue=prediction.getAnnotation();
  Recommender recommender=recommendationService.getRecommender(aVID.getId());
  AnnotationLayer layer=annotationService.getLayer(aVID.getLayerId());
  AnnotationFeature feature=annotationService.getFeature(recommender.getFeature(),layer);
  SpanAdapter adapter=(SpanAdapter)annotationService.getAdapter(layer);
  Type type=CasUtil.getType(aJCas.getCas(),layer.getName());
  AnnotationFS annoFS=WebAnnoCasUtil.selectSingleFsAt(aJCas,type,aBegin,aEnd);
  int address;
  if (annoFS != null) {
    address=WebAnnoCasUtil.getAddr(annoFS);
  }
 else {
    address=adapter.add(aState,aJCas,aBegin,aEnd);
  }
  String fsId=fsRegistry.getFeatureSupport(feature).getId();
  if (fsId.equals("String_Node_Str") || fsId.equals("String_Node_Str")) {
    String uiName=fsRegistry.getFeatureSupport(feature).renderFeatureValue(feature,predictedValue);
    KBHandle kbHandle=new KBHandle(predictedValue,uiName);
    adapter.setFeatureValue(aState,aJCas,address,feature,kbHandle);
  }
 else {
    adapter.setFeatureValue(aState,aJCas,address,feature,predictedValue);
  }
  AnnotationFS fs=WebAnnoCasUtil.selectByAddr(aJCas,AnnotationFS.class,address);
  applicationEventPublisher.publishEvent(new RecommendationAcceptedEvent(this,aState.getDocument(),aState.getUser().getUsername(),fs,feature,predictedValue));
  aState.getSelection().selectSpan(new VID(address),aJCas,aBegin,aEnd);
  aActionHandler.actionSelect(aTarget,aJCas);
  aActionHandler.actionCreateOrUpdate(aTarget,aJCas);
  aTarget.getPage().send(aTarget.getPage(),Broadcast.BREADTH,new AjaxRecommendationAcceptedEvent(aTarget,aState,aVID));
}

Fixed version (ground truth):
private void actionAcceptRecommendation(AnnotationActionHandler aActionHandler,AnnotatorState aState,AjaxRequestTarget aTarget,JCas aJCas,VID aVID,int aBegin,int aEnd) throws AnnotationException, IOException {
  SourceDocument document=aState.getDocument();
  Predictions model=recommendationService.getPredictions(aState.getUser(),aState.getProject());
  Optional<AnnotationObject> prediction=model.getPredictionByVID(document,aVID);
  if (!prediction.isPresent()) {
    log.error("String_Node_Str",document,aVID);
    aTarget.getPage().error("String_Node_Str");
    aTarget.addChildren(aTarget.getPage(),IFeedback.class);
    return;
  }
  String predictedValue=prediction.get().getAnnotation();
  Recommender recommender=recommendationService.getRecommender(aVID.getId());
  AnnotationLayer layer=annotationService.getLayer(aVID.getLayerId());
  AnnotationFeature feature=annotationService.getFeature(recommender.getFeature(),layer);
  SpanAdapter adapter=(SpanAdapter)annotationService.getAdapter(layer);
  Type type=CasUtil.getType(aJCas.getCas(),layer.getName());
  AnnotationFS annoFS=WebAnnoCasUtil.selectSingleFsAt(aJCas,type,aBegin,aEnd);
  int address;
  if (annoFS != null) {
    address=WebAnnoCasUtil.getAddr(annoFS);
  }
 else {
    address=adapter.add(aState,aJCas,aBegin,aEnd);
  }
  String fsId=fsRegistry.getFeatureSupport(feature).getId();
  if (fsId.equals("String_Node_Str") || fsId.equals("String_Node_Str")) {
    String uiName=fsRegistry.getFeatureSupport(feature).renderFeatureValue(feature,predictedValue);
    KBHandle kbHandle=new KBHandle(predictedValue,uiName);
    adapter.setFeatureValue(aState,aJCas,address,feature,kbHandle);
  }
 else {
    adapter.setFeatureValue(aState,aJCas,address,feature,predictedValue);
  }
  AnnotationFS fs=WebAnnoCasUtil.selectByAddr(aJCas,AnnotationFS.class,address);
  applicationEventPublisher.publishEvent(new RecommendationAcceptedEvent(this,document,aState.getUser().getUsername(),fs,feature,predictedValue));
  aState.getSelection().selectSpan(new VID(address),aJCas,aBegin,aEnd);
  aActionHandler.actionSelect(aTarget,aJCas);
  aActionHandler.actionCreateOrUpdate(aTarget,aJCas);
  aTarget.getPage().send(aTarget.getPage(),Broadcast.BREADTH,new AjaxRecommendationAcceptedEvent(aTarget,aState,aVID));
}