nus-yam/ex-repair huggingface dataset:
Program: 32287
Project: 32287
Buggy source:
@Transactional @RequireUser @RequireWrite @ManagesDevices @Override public Device removeDevice(Device device){
  EntityManager entityManager=getSessionEntityManager();
  User user=getSessionUser();
  device=entityManager.find(Device.class,device.getId());
  if (user.getAdmin() || user.getManager()) {
    device.getUsers().removeAll(getUsers());
  }
  device.getUsers().remove(user);
  if (device.getUsers().isEmpty()) {
    device.setLatestPosition(null);
    entityManager.flush();
    Query query=entityManager.createQuery("String_Node_Str");
    query.setParameter("String_Node_Str",device);
    query.executeUpdate();
    query=entityManager.createQuery("String_Node_Str");
    query.setParameter("String_Node_Str",device);
    query.executeUpdate();
    entityManager.remove(device);
  }
  return device;
}

Fixed version (ground truth):
@Transactional @RequireUser @RequireWrite @ManagesDevices @Override public Device removeDevice(Device device){
  EntityManager entityManager=getSessionEntityManager();
  User user=getSessionUser();
  device=entityManager.find(Device.class,device.getId());
  if (user.getAdmin() || user.getManager()) {
    device.getUsers().removeAll(getUsers());
  }
  device.getUsers().remove(user);
  if (device.getUsers().isEmpty()) {
    device.setLatestPosition(null);
    entityManager.flush();
    Query query=entityManager.createQuery("String_Node_Str");
    query.setParameter("String_Node_Str",device);
    query.executeUpdate();
    query=entityManager.createQuery("String_Node_Str");
    query.setParameter("String_Node_Str",device);
    query.executeUpdate();
    query=entityManager.createQuery("String_Node_Str");
    query.setParameter("String_Node_Str",device);
    for (    GeoFence geoFence : (List<GeoFence>)query.getResultList()) {
      geoFence.getDevices().remove(device);
    }
    entityManager.remove(device);
  }
  return device;
}
Program: 32288
Project: 32288
Buggy source:
public DeviceController(MapController mapController,DeviceView.SettingsHandler settingsHandler,ListStore<GeoFence> geoFenceStore,StoreHandlers<Device> deviceStoreHandler,Application application){
  this.application=application;
  this.mapController=mapController;
  this.deviceStoreHandler=deviceStoreHandler;
  DeviceProperties deviceProperties=GWT.create(DeviceProperties.class);
  deviceStore=new ListStore<Device>(deviceProperties.id());
  deviceStore.addStoreRecordChangeHandler(new StoreRecordChangeEvent.StoreRecordChangeHandler<Device>(){
    @Override public void onRecordChange(    StoreRecordChangeEvent<Device> event){
      if (event.getProperty().getPath().equals("String_Node_Str")) {
        boolean follow=(Boolean)event.getRecord().getValue(event.getProperty());
        Device device=event.getRecord().getModel();
        if (follow) {
          ApplicationContext.getInstance().follow(device);
        }
 else {
          ApplicationContext.getInstance().stopFollowing(device);
        }
      }
 else       if (event.getProperty().getPath().equals("String_Node_Str")) {
        boolean recordTrace=(Boolean)event.getRecord().getValue(event.getProperty());
        Device device=event.getRecord().getModel();
        if (recordTrace) {
          ApplicationContext.getInstance().recordTrace(device);
        }
 else {
          ApplicationContext.getInstance().stopRecordingTrace(device);
        }
      }
    }
  }
);
  deviceView=new DeviceView(this,geoFenceHandler,settingsHandler,deviceStore,geoFenceStore);
}

Fixed version (ground truth):
public DeviceController(MapController mapController,DeviceView.GeoFenceHandler geoFenceHandler,DeviceView.SettingsHandler settingsHandler,ListStore<GeoFence> geoFenceStore,StoreHandlers<Device> deviceStoreHandler,Application application){
  this.application=application;
  this.mapController=mapController;
  this.deviceStoreHandler=deviceStoreHandler;
  DeviceProperties deviceProperties=GWT.create(DeviceProperties.class);
  deviceStore=new ListStore<Device>(deviceProperties.id());
  deviceStore.addStoreRecordChangeHandler(new StoreRecordChangeEvent.StoreRecordChangeHandler<Device>(){
    @Override public void onRecordChange(    StoreRecordChangeEvent<Device> event){
      if (event.getProperty().getPath().equals("String_Node_Str")) {
        boolean follow=(Boolean)event.getRecord().getValue(event.getProperty());
        Device device=event.getRecord().getModel();
        if (follow) {
          ApplicationContext.getInstance().follow(device);
        }
 else {
          ApplicationContext.getInstance().stopFollowing(device);
        }
      }
 else       if (event.getProperty().getPath().equals("String_Node_Str")) {
        boolean recordTrace=(Boolean)event.getRecord().getValue(event.getProperty());
        Device device=event.getRecord().getModel();
        if (recordTrace) {
          ApplicationContext.getInstance().recordTrace(device);
        }
 else {
          ApplicationContext.getInstance().stopRecordingTrace(device);
        }
      }
    }
  }
);
  deviceView=new DeviceView(this,geoFenceHandler,settingsHandler,deviceStore,geoFenceStore);
}
Program: 32289
Project: 32289
Buggy source:
@Override protected void configureServlets(){
  String persistenceUnit;
  try {
    Context context=new InitialContext();
    context.lookup(PERSISTENCE_DATASTORE);
    persistenceUnit=PERSISTENCE_UNIT_RELEASE;
  }
 catch (  NamingException e) {
    persistenceUnit=PERSISTENCE_UNIT_DEBUG;
  }
  install(new JpaPersistModule(persistenceUnit));
  filter("String_Node_Str").through(PersistFilter.class);
  serve("String_Node_Str").with(DataServiceImpl.class);
  serve("String_Node_Str").with(UIStateServiceImpl.class);
  serve("String_Node_Str").with(EventServiceImpl.class);
  serve("String_Node_Str").with(NotificationServiceImpl.class);
  serve("String_Node_Str").with(RESTApiServlet.class);
  serve("String_Node_Str").with(ExportServlet.class);
  serve("String_Node_Str").with(ImportServlet.class);
  serve("String_Node_Str").with(LoginServlet.class);
  UserCheck userCheck=new UserCheck();
  requestInjection(userCheck);
  bindInterceptor(Matchers.any(),Matchers.annotatedWith(RequireUser.class),userCheck);
  bindInterceptor(Matchers.any(),Matchers.annotatedWith(ManagesDevices.class),userCheck);
  bind(User.class).toProvider(CurrentUserProvider.class);
  bind(ApplicationSettings.class).toProvider(ApplicationSettingsProvider.class);
  bind(DataService.class).to(DataServiceImpl.class);
  bind(EventService.class).to(EventServiceImpl.class);
}

Fixed version (ground truth):
@Override protected void configureServlets(){
  String persistenceUnit;
  try {
    Context context=new InitialContext();
    context.lookup(PERSISTENCE_DATASTORE);
    persistenceUnit=PERSISTENCE_UNIT_RELEASE;
  }
 catch (  NamingException e) {
    persistenceUnit=PERSISTENCE_UNIT_DEBUG;
  }
  install(new JpaPersistModule(persistenceUnit));
  filter("String_Node_Str").through(PersistFilter.class);
  serve("String_Node_Str").with(DataServiceImpl.class);
  serve("String_Node_Str").with(UIStateServiceImpl.class);
  serve("String_Node_Str").with(EventServiceImpl.class);
  serve("String_Node_Str").with(NotificationServiceImpl.class);
  serve("String_Node_Str").with(RESTApiServlet.class);
  serve("String_Node_Str").with(ExportServlet.class);
  serve("String_Node_Str").with(ImportServlet.class);
  serve("String_Node_Str").with(LoginServlet.class);
  UserCheck userCheck=new UserCheck();
  requestInjection(userCheck);
  bindInterceptor(Matchers.any(),Matchers.annotatedWith(RequireUser.class),userCheck);
  bindInterceptor(Matchers.any(),Matchers.annotatedWith(ManagesDevices.class),userCheck);
  bindInterceptor(Matchers.any(),Matchers.annotatedWith(RequireWrite.class),userCheck);
  bind(User.class).toProvider(CurrentUserProvider.class);
  bind(ApplicationSettings.class).toProvider(ApplicationSettingsProvider.class);
  bind(DataService.class).to(DataServiceImpl.class);
  bind(EventService.class).to(EventServiceImpl.class);
}
Program: 32290
Project: 32290
Buggy source:
@Override protected Injector getInjector(){
  return Guice.createInjector(new ServletModule(){
    @Override protected void configureServlets(){
      String persistenceUnit;
      try {
        Context context=new InitialContext();
        context.lookup(PERSISTENCE_DATASTORE);
        persistenceUnit=PERSISTENCE_UNIT_RELEASE;
      }
 catch (      NamingException e) {
        persistenceUnit=PERSISTENCE_UNIT_DEBUG;
      }
      install(new JpaPersistModule(persistenceUnit));
      filter("String_Node_Str").through(PersistFilter.class);
      serve("String_Node_Str").with(DataServiceImpl.class);
      serve("String_Node_Str").with(UIStateServiceImpl.class);
      serve("String_Node_Str").with(EventServiceImpl.class);
      serve("String_Node_Str").with(NotificationServiceImpl.class);
      serve("String_Node_Str").with(RESTApiServlet.class);
      serve("String_Node_Str").with(ExportServlet.class);
      serve("String_Node_Str").with(ImportServlet.class);
      serve("String_Node_Str").with(LoginServlet.class);
      UserCheck userCheck=new UserCheck();
      requestInjection(userCheck);
      bindInterceptor(Matchers.any(),Matchers.annotatedWith(RequireUser.class),userCheck);
      bindInterceptor(Matchers.any(),Matchers.annotatedWith(ManagesDevices.class),userCheck);
      bind(User.class).toProvider(CurrentUserProvider.class);
      bind(ApplicationSettings.class).toProvider(ApplicationSettingsProvider.class);
      bind(DataService.class).to(DataServiceImpl.class);
      bind(EventService.class).to(EventServiceImpl.class);
    }
  }
);
}

Fixed version (ground truth):
@Override protected Injector getInjector(){
  return Guice.createInjector(getModule());
}
Program: 32291
Project: 32291
Buggy source:
void checkRequireUser(RequireUser requireUser){
  User user=sessionUser.get();
  if (user == null) {
    throw new SecurityException("String_Node_Str");
  }
  if (requireUser.roles().length > 0) {
    StringBuilder roles=new StringBuilder();
    for (    Role role : requireUser.roles()) {
      if (roles.length() > 0) {
        roles.append("String_Node_Str");
      }
      roles.append(role.toString());
      if (role.has(user)) {
        return;
      }
    }
    throw new SecurityException("String_Node_Str" + roles + "String_Node_Str");
  }
}

Fixed version (ground truth):
void checkRequireUser(RequireUser requireUser){
  if (rolesChecked.get() != null) {
    if (requireUser.roles().length == 0) {
      return;
    }
    Role[] checkedRoles=rolesChecked.get();
    for (    Role role : requireUser.roles()) {
      for (int i=0; i < checkedRoles.length; i++) {
        if (role == checkedRoles[i]) {
          return;
        }
      }
    }
  }
  User user=sessionUser.get();
  if (user == null) {
    throw new SecurityException("String_Node_Str");
  }
  if (requireUser.roles().length > 0) {
    StringBuilder roles=new StringBuilder();
    for (    Role role : requireUser.roles()) {
      if (roles.length() > 0) {
        roles.append("String_Node_Str");
      }
      roles.append(role.toString());
      if (role.has(user)) {
        rolesChecked.set(requireUser.roles());
        return;
      }
    }
    throw new SecurityException("String_Node_Str" + roles + "String_Node_Str");
  }
 else {
    rolesChecked.set(requireUser.roles());
  }
}
Program: 32292
Project: 32292
Buggy source:
void checkRequireWrite(RequireWrite requireWrite){
  User user=sessionUser.get();
  if (user == null) {
    throw new SecurityException("String_Node_Str");
  }
  if (user.getReadOnly()) {
    throw new SecurityException("String_Node_Str");
  }
}

Fixed version (ground truth):
void checkRequireWrite(RequireWrite requireWrite){
  if (checkedRequireWrite.get() != null) {
    return;
  }
  User user=sessionUser.get();
  if (user == null) {
    throw new SecurityException("String_Node_Str");
  }
  if (user.getReadOnly()) {
    throw new SecurityException("String_Node_Str");
  }
  checkedRequireWrite.set(Boolean.TRUE);
}
Program: 32293
Project: 32293
Buggy source:
@Override public Object invoke(MethodInvocation methodInvocation) throws Throwable {
  RequireUser requireUser=methodInvocation.getMethod().getAnnotation(RequireUser.class);
  if (requireUser != null)   checkRequireUser(requireUser);
  ManagesDevices managesDevices=methodInvocation.getMethod().getAnnotation(ManagesDevices.class);
  if (managesDevices != null)   checkDeviceManagementAccess(managesDevices);
  RequireWrite requireWrite=methodInvocation.getMethod().getAnnotation(RequireWrite.class);
  if (requireWrite != null)   checkRequireWrite(requireWrite);
  return methodInvocation.proceed();
}

Fixed version (ground truth):
@Override public Object invoke(MethodInvocation methodInvocation) throws Throwable {
  RequireUser requireUser=methodInvocation.getMethod().getAnnotation(RequireUser.class);
  if (requireUser != null)   checkRequireUser(requireUser);
  ManagesDevices managesDevices=methodInvocation.getMethod().getAnnotation(ManagesDevices.class);
  if (managesDevices != null)   checkDeviceManagementAccess(managesDevices);
  RequireWrite requireWrite=methodInvocation.getMethod().getAnnotation(RequireWrite.class);
  if (requireWrite != null)   checkRequireWrite(requireWrite);
  try {
    return methodInvocation.proceed();
  }
  finally {
    cleanUp();
  }
}
Program: 32294
Project: 32294
Buggy source:
void checkDeviceManagementAccess(ManagesDevices managesDevices) throws Throwable {
  User user=sessionUser.get();
  if (user == null) {
    throw new SecurityException("String_Node_Str");
  }
  if (!user.getAdmin() && !user.getManager()) {
    ApplicationSettings applicationSettings=entityManager.get().createQuery("String_Node_Str",ApplicationSettings.class).getSingleResult();
    if (applicationSettings.isDisallowDeviceManagementByUsers()) {
      throw new SecurityException("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
void checkDeviceManagementAccess(ManagesDevices managesDevices) throws Throwable {
  if (checkedDeviceManagement.get() != null) {
    return;
  }
  User user=sessionUser.get();
  if (user == null) {
    throw new SecurityException("String_Node_Str");
  }
  if (!user.getAdmin() && !user.getManager()) {
    if (applicationSettings.get().isDisallowDeviceManagementByUsers()) {
      throw new SecurityException("String_Node_Str");
    }
    checkedDeviceManagement.set(Boolean.TRUE);
  }
}
Program: 32296
Project: 32296
Buggy source:
@Transactional @RequireUser(roles={Role.ADMIN,Role.MANAGER}) @Override public User removeUser(User user){
  EntityManager entityManager=getSessionEntityManager();
  user=entityManager.merge(user);
  for (  Device device : user.getDevices()) {
    device.getUsers().remove(user);
  }
  entityManager.remove(user);
  return user;
}

Fixed version (ground truth):
@Transactional @RequireUser(roles={Role.ADMIN,Role.MANAGER}) @Override public User removeUser(User user){
  EntityManager entityManager=getSessionEntityManager();
  user=entityManager.merge(user);
  if (user.equals(getSessionUser())) {
    throw new IllegalArgumentException();
  }
  if (!user.getAdmin() && !user.getAllManagedUsers().contains(user)) {
    throw new SecurityException();
  }
  entityManager.createQuery("String_Node_Str").setParameter("String_Node_Str",user).executeUpdate();
  for (  Device device : user.getDevices()) {
    device.getUsers().remove(user);
  }
  entityManager.remove(user);
  return user;
}
Program: 32298
Project: 32298
Buggy source:
@UiHandler("String_Node_Str") public void onSaveClicked(SelectEvent event){
  window.hide();
  Device device=driver.flush();
  device.setIdleSpeedThreshold(ApplicationContext.getInstance().getUserSettings().getSpeedUnit().toKnots(device.getIdleSpeedThreshold()));
  device.setIconType(DeviceIconType.valueOf(((Radio)iconRadioGroup.getValue()).getId()));
  deviceHandler.onSave(device);
}

Fixed version (ground truth):
@UiHandler("String_Node_Str") public void onSaveClicked(SelectEvent event){
  window.hide();
  Device device=driver.flush();
  device.setIdleSpeedThreshold(ApplicationContext.getInstance().getUserSettings().getSpeedUnit().toKnots(device.getIdleSpeedThreshold()));
  if (iconRadioGroup.getValue() != null) {
    device.setIconType(DeviceIconType.valueOf(((Radio)iconRadioGroup.getValue()).getId()));
  }
  deviceHandler.onSave(device);
}
Program: 32299
Project: 32299
Buggy source:
@RequireUser @Transactional @Override public List<Position> getLatestNonIdlePositions(){
  List<Position> positions=new LinkedList<Position>();
  List<Device> devices=getDevices();
  if (devices != null && !devices.isEmpty()) {
    EntityManager entityManager=getSessionEntityManager();
    for (    Device device : devices) {
      Position position=(Position)entityManager.createQuery("String_Node_Str").setParameter("String_Node_Str",device).setMaxResults(1).getSingleResult();
      if (position != null) {
        positions.add(position);
      }
    }
  }
  return positions;
}

Fixed version (ground truth):
@RequireUser @Transactional @Override public List<Position> getLatestNonIdlePositions(){
  List<Position> positions=new LinkedList<Position>();
  List<Device> devices=getDevices();
  if (devices != null && !devices.isEmpty()) {
    EntityManager entityManager=getSessionEntityManager();
    for (    Device device : devices) {
      List<Position> position=entityManager.createQuery("String_Node_Str",Position.class).setParameter("String_Node_Str",device).setMaxResults(1).getResultList();
      if (position.isEmpty()) {
        position=entityManager.createQuery("String_Node_Str",Position.class).setParameter("String_Node_Str",device).setMaxResults(1).getResultList();
      }
      if (!position.isEmpty()) {
        positions.add(position.get(0));
      }
    }
  }
  return positions;
}
Program: 32300
Project: 32300
Buggy source:
@Override protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  if (perThreadRequest == null) {
    getThreadLocalRequest();
  }
  if (perThreadResponse == null) {
    getThreadLocalResponse();
  }
  perThreadRequest.set(req);
  perThreadResponse.set(resp);
  try {
    String payload=RPCServletUtils.readContent(req,null,null);
    String result=makeRestCall(payload);
    if (result != null) {
      resp.getWriter().write(result);
      if (resp.getStatus() != HttpServletResponse.SC_INTERNAL_SERVER_ERROR && resp.getStatus() != HttpServletResponse.SC_UNAUTHORIZED && resp.getStatus() != HttpServletResponse.SC_NOT_FOUND) {
        resp.setStatus(HttpServletResponse.SC_OK);
      }
    }
  }
  finally {
    perThreadRequest.set(null);
    perThreadResponse.set(null);
  }
}

Fixed version (ground truth):
@Override protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  if (perThreadRequest == null) {
    getThreadLocalRequest();
  }
  if (perThreadResponse == null) {
    getThreadLocalResponse();
  }
  perThreadRequest.set(req);
  perThreadResponse.set(resp);
  try {
    String payload=RPCServletUtils.readContent(req,null,null);
    String result=makeRestCall(payload);
    if (result != null) {
      resp.setHeader("String_Node_Str","String_Node_Str");
      resp.setCharacterEncoding("String_Node_Str");
      resp.getWriter().write(result);
      if (resp.getStatus() != HttpServletResponse.SC_INTERNAL_SERVER_ERROR && resp.getStatus() != HttpServletResponse.SC_UNAUTHORIZED && resp.getStatus() != HttpServletResponse.SC_NOT_FOUND) {
        resp.setStatus(HttpServletResponse.SC_OK);
      }
    }
  }
  finally {
    perThreadRequest.set(null);
    perThreadResponse.set(null);
  }
}
Program: 32301
Project: 32301
Buggy source:
@Override public void migrate(EntityManager em) throws Exception {
  em.createQuery("String_Node_Str" + Device.class.getSimpleName() + "String_Node_Str").setParameter("String_Node_Str",Integer.valueOf(Device.DEFAULT_TIMEOUT)).executeUpdate();
}

Fixed version (ground truth):
@Override public void migrate(EntityManager em) throws Exception {
  em.createQuery("String_Node_Str" + ApplicationSettings.class.getName() + "String_Node_Str").setParameter("String_Node_Str",Boolean.FALSE).executeUpdate();
}
Program: 32303
Project: 32303
Buggy source:
@Override public boolean logout(){
  setSessionUser(null);
  return true;
}

Fixed version (ground truth):
@Override public boolean logout(){
  setSessionUser(null);
  HttpSession session=getThreadLocalRequest().getSession();
  EntityManager entityManager=(EntityManager)session.getAttribute(ATTRIBUTE_ENTITYMANAGER);
  if (entityManager != null) {
    entityManager.close();
    session.removeAttribute(ATTRIBUTE_ENTITYMANAGER);
  }
  return true;
}
Program: 32305
Project: 32305
Buggy source:
public static BHttpRequestResponse create(IHttpRequestResponse requestResponse,IBurpExtenderCallbacks callbacks,IExtensionHelpers helpers){
  BHttpRequestResponse bHttpRequestResponse=new BHttpRequestResponse();
  bHttpRequestResponse.request=BHttpRequestFactory.create(0x00004242,requestResponse,helpers.analyzeRequest(requestResponse),callbacks);
  bHttpRequestResponse.response=BHttpResponseFactory.create(0x00004242,requestResponse,helpers.analyzeResponse(requestResponse.getResponse()),callbacks);
  bHttpRequestResponse.messageType="String_Node_Str";
  return bHttpRequestResponse;
}

Fixed version (ground truth):
public static BHttpRequestResponse create(IHttpRequestResponse requestResponse,IBurpExtenderCallbacks callbacks,IExtensionHelpers helpers){
  BHttpRequestResponse bHttpRequestResponse=new BHttpRequestResponse();
  if (requestResponse.getRequest() != null && requestResponse.getRequest().length > 0) {
    bHttpRequestResponse.request=BHttpRequestFactory.create(0x00004242,requestResponse,helpers.analyzeRequest(requestResponse),callbacks);
  }
  if (requestResponse.getResponse() != null && requestResponse.getResponse().length > 0) {
    bHttpRequestResponse.response=BHttpResponseFactory.create(0x00004242,requestResponse,helpers.analyzeResponse(requestResponse.getResponse()),callbacks);
  }
  bHttpRequestResponse.messageType="String_Node_Str";
  return bHttpRequestResponse;
}
Program: 32308
Project: 32308
Buggy source:
public ApiServer(String ip,int port,IBurpExtenderCallbacks callbacks){
  setPort(port);
  setIpAddress(ip);
  Gson gson=new Gson();
  get("String_Node_Str",(request,response) -> {
    IScanIssue[] rawIssues=callbacks.getScanIssues("String_Node_Str");
    List<BScanIssue> issues=new ArrayList<>();
    for (    IScanIssue issue : rawIssues) {
      issues.add(BScanIssueFactory.create(issue,callbacks));
    }
    return gson.toJson(issues);
  }
);
  post("String_Node_Str",(request,response) -> {
    BScanIssue issue=gson.fromJson(request.body(),BScanIssue.class);
    callbacks.addScanIssue(issue);
    response.status(201);
    return gson.toJson(issue);
  }
);
}

Fixed version (ground truth):
public ApiServer(String ip,int port,IBurpExtenderCallbacks callbacks){
  setPort(port);
  setIpAddress(ip);
  Gson gson=new Gson();
  get("String_Node_Str",(request,response) -> {
    IScanIssue[] rawIssues=callbacks.getScanIssues("String_Node_Str");
    List<BScanIssue> issues=new ArrayList<>();
    for (    IScanIssue issue : rawIssues) {
      issues.add(BScanIssueFactory.create(issue,callbacks));
    }
    return gson.toJson(issues);
  }
);
  get("String_Node_Str",(request,response) -> {
    byte[] encodedBytes=Base64.decodeBase64(request.params("String_Node_Str"));
    IScanIssue[] rawIssues=callbacks.getScanIssues(new String(encodedBytes));
    List<BScanIssue> issues=new ArrayList<>();
    for (    IScanIssue issue : rawIssues) {
      issues.add(BScanIssueFactory.create(issue,callbacks));
    }
    return gson.toJson(issues);
  }
);
  post("String_Node_Str",(request,response) -> {
    BScanIssue issue=gson.fromJson(request.body(),BScanIssue.class);
    callbacks.addScanIssue(issue);
    response.status(201);
    return gson.toJson(issue);
  }
);
}
Program: 32309
Project: 32309
Buggy source:
public void setYFraction(float fraction){
  this.yFraction=fraction;
  if (getHeight() == 0) {
    if (preDrawListener == null) {
      preDrawListener=new ViewTreeObserver.OnPreDrawListener(){
        @Override public boolean onPreDraw(){
          getViewTreeObserver().removeOnPreDrawListener(preDrawListener);
          setYFraction(yFraction);
          return true;
        }
      }
;
    }
    getViewTreeObserver().addOnPreDrawListener(preDrawListener);
    return;
  }
  float translationY=getHeight() * fraction;
  setTranslationY(translationY);
}

Fixed version (ground truth):
public void setYFraction(float fraction){
  this.yFraction=fraction;
  if (getHeight() == 0) {
    if (preDrawListener == null) {
      preDrawListener=new ViewTreeObserver.OnPreDrawListener(){
        @Override public boolean onPreDraw(){
          getViewTreeObserver().removeOnPreDrawListener(preDrawListener);
          setYFraction(yFraction);
          return true;
        }
      }
;
      getViewTreeObserver().addOnPreDrawListener(preDrawListener);
    }
    return;
  }
  float translationY=getHeight() * fraction;
  setTranslationY(translationY);
}
Program: 32310
Project: 32310
Buggy source:
public VocabularyIndexAnalyzer() throws IOException, URISyntaxException {
  super(PER_FIELD_REUSE_STRATEGY);
  Map<String,Analyzer> fieldAnalyzers=new HashMap<>();
  fieldAnalyzers.put(NodeProperties.LABEL,new TermAnalyzer());
  fieldAnalyzers.put(NodeProperties.LABEL + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.SYNONYM,new TermAnalyzer());
  fieldAnalyzers.put(Concept.SYNONYM + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.ABREVIATION,new TermAnalyzer());
  fieldAnalyzers.put(Concept.ABREVIATION + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.ACRONYM,new TermAnalyzer());
  fieldAnalyzers.put(Concept.ACRONYM + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  analyzer=new PerFieldAnalyzerWrapper(new KeywordAnalyzer(),fieldAnalyzers);
}

Fixed version (ground truth):
public VocabularyIndexAnalyzer() throws IOException, URISyntaxException {
  super(NO_REUSE_STRATEGY);
  Map<String,Analyzer> fieldAnalyzers=new HashMap<>();
  fieldAnalyzers.put(NodeProperties.LABEL,new TermAnalyzer());
  fieldAnalyzers.put(NodeProperties.LABEL + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.SYNONYM,new TermAnalyzer());
  fieldAnalyzers.put(Concept.SYNONYM + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.ABREVIATION,new TermAnalyzer());
  fieldAnalyzers.put(Concept.ABREVIATION + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.ACRONYM,new TermAnalyzer());
  fieldAnalyzers.put(Concept.ACRONYM + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  analyzer=new PerFieldAnalyzerWrapper(new KeywordAnalyzer(),fieldAnalyzers);
}
Program: 32311
Project: 32311
Buggy source:
public VocabularyQueryAnalyzer(){
  super(PER_FIELD_REUSE_STRATEGY);
  Map<String,Analyzer> fieldAnalyzers=new HashMap<>();
  fieldAnalyzers.put(NodeProperties.LABEL,new TermAnalyzer());
  fieldAnalyzers.put(NodeProperties.LABEL + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.SYNONYM,new TermAnalyzer());
  fieldAnalyzers.put(Concept.SYNONYM + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.ABREVIATION,new TermAnalyzer());
  fieldAnalyzers.put(Concept.ABREVIATION + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.ACRONYM,new TermAnalyzer());
  fieldAnalyzers.put(Concept.ACRONYM + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  analyzer=new PerFieldAnalyzerWrapper(new KeywordAnalyzer(),fieldAnalyzers);
}

Fixed version (ground truth):
public VocabularyQueryAnalyzer(){
  Map<String,Analyzer> fieldAnalyzers=new HashMap<>();
  fieldAnalyzers.put(NodeProperties.LABEL,new TermAnalyzer());
  fieldAnalyzers.put(NodeProperties.LABEL + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.SYNONYM,new TermAnalyzer());
  fieldAnalyzers.put(Concept.SYNONYM + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.ABREVIATION,new TermAnalyzer());
  fieldAnalyzers.put(Concept.ABREVIATION + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  fieldAnalyzers.put(Concept.ACRONYM,new TermAnalyzer());
  fieldAnalyzers.put(Concept.ACRONYM + LuceneUtils.EXACT_SUFFIX,new ExactAnalyzer());
  analyzer=new PerFieldAnalyzerWrapper(new KeywordAnalyzer(),fieldAnalyzers);
}
Program: 32314
Project: 32314
Buggy source:
@Override public Map<String,Set<Long>> call() throws Exception {
  logger.info("String_Node_Str" + category);
  Map<String,Set<Long>> map=new HashMap<String,Set<Long>>();
  Set<Long> nodeSet=new HashSet<Long>();
  Transaction tx=graphDb.beginTx();
  for (  Path position : graphDb.traversalDescription().uniqueness(Uniqueness.NODE_GLOBAL).depthFirst().relationships(OwlRelationships.RDFS_SUBCLASS_OF,Direction.INCOMING).relationships(OwlRelationships.RDF_TYPE,Direction.INCOMING).relationships(OwlRelationships.OWL_EQUIVALENT_CLASS,Direction.BOTH).relationships(OwlRelationships.OWL_SAME_AS,Direction.BOTH).traverse(root)) {
    Node end=position.endNode();
    nodeSet.add(end.getId());
  }
  tx.success();
  tx.close();
  logger.info("String_Node_Str" + nodeSet.size() + "String_Node_Str"+ category);
  map.put(category,nodeSet);
  return map;
}

Fixed version (ground truth):
@Override public Map<String,Set<Long>> call() throws Exception {
  logger.info("String_Node_Str" + category);
  Map<String,Set<Long>> map=new HashMap<String,Set<Long>>();
  Set<Long> nodeSet=new HashSet<Long>();
  Transaction tx=graphDb.beginTx();
  try {
    for (    Path position : graphDb.traversalDescription().uniqueness(Uniqueness.NODE_GLOBAL).depthFirst().relationships(OwlRelationships.RDFS_SUBCLASS_OF,Direction.INCOMING).relationships(OwlRelationships.RDF_TYPE,Direction.INCOMING).relationships(OwlRelationships.OWL_EQUIVALENT_CLASS,Direction.BOTH).relationships(OwlRelationships.OWL_SAME_AS,Direction.BOTH).traverse(root)) {
      Node end=position.endNode();
      nodeSet.add(end.getId());
    }
    logger.info("String_Node_Str" + nodeSet.size() + "String_Node_Str"+ category);
    map.put(category,nodeSet);
  }
 catch (  Exception e) {
    logger.warning("String_Node_Str" + category);
  }
 finally {
    tx.success();
    tx.close();
  }
  return map;
}
Program: 32316
Project: 32316
Buggy source:
private void moveEdgesToLeader(Node leader,List<Node> clique,Transaction tx){
  for (  Node n : clique) {
    logger.fine("String_Node_Str" + n.getProperty(NodeProperties.IRI));
    int edgesMoved=0;
    Iterable<Relationship> rels=n.getRelationships();
    for (    Relationship rel : rels) {
      if ((isOneOfType(rel,relationships)) && (rel.getStartNode().getId() == leader.getId() || rel.getEndNode().getId() == leader.getId())) {
        logger.fine("String_Node_Str");
      }
 else {
        if ((rel.getEndNode().getId() == n.getId())) {
          logger.fine("String_Node_Str" + rel.getId() + "String_Node_Str"+ n.getProperty(NodeProperties.IRI)+ "String_Node_Str"+ leader.getProperty(NodeProperties.IRI));
          moveRelationship(n,leader,rel,ORIGINAL_REFERENCE_KEY_TARGET);
        }
 else         if ((rel.getStartNode().getId() == n.getId())) {
          logger.fine("String_Node_Str" + rel.getId() + "String_Node_Str"+ n.getProperty(NodeProperties.IRI)+ "String_Node_Str"+ leader.getProperty(NodeProperties.IRI));
          moveRelationship(n,leader,rel,ORIGINAL_REFERENCE_KEY_SOURCE);
        }
      }
      edgesMoved+=1;
      if (edgesMoved >= 100) {
        tx.success();
        tx.close();
        tx=graphDb.beginTx();
        edgesMoved=0;
      }
    }
  }
}

Fixed version (ground truth):
private void moveEdgesToLeader(Node leader,List<Node> clique,Transaction tx){
  for (  Node n : clique) {
    logger.fine("String_Node_Str" + n.getProperty(NodeProperties.IRI));
    int edgesMoved=0;
    Iterable<Relationship> rels=n.getRelationships();
    for (    Relationship rel : rels) {
      if ((isOneOfType(rel,relationships)) && (rel.getStartNode().getId() == leader.getId() || rel.getEndNode().getId() == leader.getId())) {
        logger.fine("String_Node_Str");
      }
 else {
        if ((rel.getEndNode().getId() == n.getId())) {
          logger.fine("String_Node_Str" + rel.getId() + "String_Node_Str"+ n.getProperty(NodeProperties.IRI)+ "String_Node_Str"+ leader.getProperty(NodeProperties.IRI));
          moveRelationship(n,leader,rel,ORIGINAL_REFERENCE_KEY_TARGET);
        }
 else         if ((rel.getStartNode().getId() == n.getId())) {
          logger.fine("String_Node_Str" + rel.getId() + "String_Node_Str"+ n.getProperty(NodeProperties.IRI)+ "String_Node_Str"+ leader.getProperty(NodeProperties.IRI));
          moveRelationship(n,leader,rel,ORIGINAL_REFERENCE_KEY_SOURCE);
        }
      }
      edgesMoved+=1;
      if (edgesMoved >= 100) {
        logger.fine("String_Node_Str" + leader.getProperty(NodeProperties.IRI) + "String_Node_Str"+ n.getProperty(NodeProperties.IRI));
        tx.success();
        tx.close();
        tx=graphDb.beginTx();
        edgesMoved=0;
      }
    }
    deleteEdges(n,tx);
  }
}
Program: 32318
Project: 32318
Buggy source:
private void moveRelationship(Node from,Node to,Relationship rel,String property){
  Relationship newRel=null;
  if (property == ORIGINAL_REFERENCE_KEY_TARGET) {
    newRel=rel.getOtherNode(from).createRelationshipTo(to,rel.getType());
  }
 else {
    newRel=to.createRelationshipTo(rel.getOtherNode(from),rel.getType());
  }
  copyProperties(rel,newRel);
  rel.delete();
  newRel.setProperty(property,from.getProperty(NodeProperties.IRI));
}

Fixed version (ground truth):
private void moveRelationship(Node from,Node to,Relationship rel,String property){
  Relationship newRel=null;
  logger.fine("String_Node_Str" + rel.getOtherNode(from).getId() + "String_Node_Str"+ to.getId());
  if (property == ORIGINAL_REFERENCE_KEY_TARGET) {
    newRel=rel.getOtherNode(from).createRelationshipTo(to,rel.getType());
  }
 else {
    newRel=to.createRelationshipTo(rel.getOtherNode(from),rel.getType());
  }
  copyProperties(rel,newRel);
  rel.setProperty(REL_TO_REMOVE,true);
  newRel.setProperty(property,from.getProperty(NodeProperties.IRI));
}
Program: 32319
Project: 32319
Buggy source:
private void moveEdgesToLeader(Node leader,List<Node> clique,Transaction tx){
  for (  Node n : clique) {
    logger.fine("String_Node_Str" + n.getProperty(NodeProperties.IRI));
    int edgesMoved=0;
    Iterable<Relationship> rels=n.getRelationships();
    for (    Relationship rel : rels) {
      if ((isOneOfType(rel,relationships)) && (rel.getStartNode().getId() == leader.getId() || rel.getEndNode().getId() == leader.getId())) {
        logger.fine("String_Node_Str");
      }
 else {
        if ((rel.getEndNode().getId() == n.getId())) {
          logger.fine("String_Node_Str" + rel.getId() + "String_Node_Str"+ n.getProperty(NodeProperties.IRI)+ "String_Node_Str"+ leader.getProperty(NodeProperties.IRI));
          moveRelationship(n,leader,rel,ORIGINAL_REFERENCE_KEY_TARGET);
        }
 else         if ((rel.getStartNode().getId() == n.getId())) {
          logger.fine("String_Node_Str" + rel.getId() + "String_Node_Str"+ n.getProperty(NodeProperties.IRI)+ "String_Node_Str"+ leader.getProperty(NodeProperties.IRI));
          moveRelationship(n,leader,rel,ORIGINAL_REFERENCE_KEY_SOURCE);
        }
      }
      edgesMoved+=1;
      if (edgesMoved > 1000) {
        tx.success();
        tx.close();
        tx=graphDb.beginTx();
        edgesMoved=0;
      }
    }
  }
}

Fixed version (ground truth):
private void moveEdgesToLeader(Node leader,List<Node> clique,Transaction tx){
  for (  Node n : clique) {
    logger.fine("String_Node_Str" + n.getProperty(NodeProperties.IRI));
    int edgesMoved=0;
    Iterable<Relationship> rels=n.getRelationships();
    for (    Relationship rel : rels) {
      if ((isOneOfType(rel,relationships)) && (rel.getStartNode().getId() == leader.getId() || rel.getEndNode().getId() == leader.getId())) {
        logger.fine("String_Node_Str");
      }
 else {
        if ((rel.getEndNode().getId() == n.getId())) {
          logger.fine("String_Node_Str" + rel.getId() + "String_Node_Str"+ n.getProperty(NodeProperties.IRI)+ "String_Node_Str"+ leader.getProperty(NodeProperties.IRI));
          moveRelationship(n,leader,rel,ORIGINAL_REFERENCE_KEY_TARGET);
        }
 else         if ((rel.getStartNode().getId() == n.getId())) {
          logger.fine("String_Node_Str" + rel.getId() + "String_Node_Str"+ n.getProperty(NodeProperties.IRI)+ "String_Node_Str"+ leader.getProperty(NodeProperties.IRI));
          moveRelationship(n,leader,rel,ORIGINAL_REFERENCE_KEY_SOURCE);
        }
      }
      edgesMoved+=1;
      if (edgesMoved >= 100) {
        tx.success();
        tx.close();
        tx=graphDb.beginTx();
        edgesMoved=0;
      }
    }
  }
}
Program: 32320
Project: 32320
Buggy source:
private Node filterByPrefix(List<Node> clique,List<String> leaderPriorityIri){
  List<Node> filteredByPrefix=new ArrayList<Node>();
  if (!leaderPriorityIri.isEmpty()) {
    String iriPriority=leaderPriorityIri.get(0);
    for (    Node n : clique) {
      Optional<String> iri=GraphUtil.getProperty(n,NodeProperties.IRI,String.class);
      if (iri.isPresent() && iri.get().contains(iriPriority)) {
        filteredByPrefix.add(n);
      }
    }
    if (filteredByPrefix.isEmpty()) {
      filterByPrefix(clique,leaderPriorityIri.subList(1,leaderPriorityIri.size()));
    }
  }
  if (filteredByPrefix.isEmpty()) {
    filteredByPrefix=clique;
  }
  Collections.sort(filteredByPrefix,new Comparator<Node>(){
    @Override public int compare(    Node node1,    Node node2){
      Optional<String> iri1=GraphUtil.getProperty(node1,NodeProperties.IRI,String.class);
      Optional<String> iri2=GraphUtil.getProperty(node2,NodeProperties.IRI,String.class);
      return iri1.get().compareTo(iri2.get());
    }
  }
);
  List<Node> filteredByPrefixAndForbiddenLabels=new ArrayList<Node>();
  for (  Node n : filteredByPrefix) {
    if (!containsOneLabel(n,forbiddenLabels)) {
      filteredByPrefixAndForbiddenLabels.add(n);
    }
  }
  if (filteredByPrefixAndForbiddenLabels.isEmpty()) {
    return filteredByPrefix.get(0);
  }
 else {
    return filteredByPrefixAndForbiddenLabels.get(0);
  }
}

Fixed version (ground truth):
private Node filterByPrefix(List<Node> clique,List<String> leaderPriorityIri){
  List<Node> filteredByPrefix=new ArrayList<Node>();
  if (!leaderPriorityIri.isEmpty()) {
    String iriPriority=leaderPriorityIri.get(0);
    for (    Node n : clique) {
      Optional<String> iri=GraphUtil.getProperty(n,NodeProperties.IRI,String.class);
      if (iri.isPresent() && iri.get().contains(iriPriority)) {
        filteredByPrefix.add(n);
      }
    }
    if (filteredByPrefix.isEmpty()) {
      filteredByPrefix.add(filterByPrefix(clique,leaderPriorityIri.subList(1,leaderPriorityIri.size())));
    }
  }
  if (filteredByPrefix.isEmpty()) {
    filteredByPrefix=clique;
  }
  Collections.sort(filteredByPrefix,new Comparator<Node>(){
    @Override public int compare(    Node node1,    Node node2){
      Optional<String> iri1=GraphUtil.getProperty(node1,NodeProperties.IRI,String.class);
      Optional<String> iri2=GraphUtil.getProperty(node2,NodeProperties.IRI,String.class);
      return iri1.get().compareTo(iri2.get());
    }
  }
);
  List<Node> filteredByPrefixAndForbiddenLabels=new ArrayList<Node>();
  for (  Node n : filteredByPrefix) {
    if (!containsOneLabel(n,forbiddenLabels)) {
      filteredByPrefixAndForbiddenLabels.add(n);
    }
  }
  if (filteredByPrefixAndForbiddenLabels.isEmpty()) {
    return filteredByPrefix.get(0);
  }
 else {
    return filteredByPrefixAndForbiddenLabels.get(0);
  }
}
Program: 32321
Project: 32321
Buggy source:
@Override public void invoke(Graph graph){
  GlobalGraphOperations globalGraphOperations=GlobalGraphOperations.at(graphDb);
  Transaction tx=graphDb.beginTx();
  ResourceIterable<Node> allNodes=globalGraphOperations.getAllNodes();
  int size=Iterators.size(allNodes.iterator());
  tx.success();
  logger.fine(size + "String_Node_Str");
  for (  Node baseNode : allNodes) {
    size-=1;
    if (size % 10 == 0) {
      tx.success();
      tx.close();
      tx=graphDb.beginTx();
    }
    if (size % 100000 == 0) {
      logger.info(size + "String_Node_Str");
    }
    if (!baseNode.hasLabel(OwlLabels.OWL_ANONYMOUS)) {
      logger.fine("String_Node_Str" + baseNode.getProperty(NodeProperties.IRI));
      if (!baseNode.hasRelationship(IS_EQUIVALENT) && !baseNode.hasRelationship(SAME_AS)) {
        markAsCliqueLeader(baseNode);
      }
 else {
        List<Node> clique=new ArrayList<Node>();
        for (        Node currentNode : graphDb.traversalDescription().relationships(IS_EQUIVALENT,Direction.BOTH).relationships(SAME_AS,Direction.BOTH).uniqueness(Uniqueness.NODE_GLOBAL).traverse(baseNode).nodes()) {
          clique.add(currentNode);
        }
        if (!hasLeader(clique)) {
          Node leader=electCliqueLeader(clique,prefixLeaderPriority);
          markAsCliqueLeader(leader);
          clique.remove(leader);
          markLeaderEdges(leader);
          moveEdgesToLeader(leader,clique);
          ensureLabel(leader,clique);
        }
      }
    }
  }
  tx.success();
}

Fixed version (ground truth):
@Override public void invoke(Graph graph){
  GlobalGraphOperations globalGraphOperations=GlobalGraphOperations.at(graphDb);
  Transaction tx=graphDb.beginTx();
  ResourceIterable<Node> allNodes=globalGraphOperations.getAllNodes();
  int size=Iterators.size(allNodes.iterator());
  tx.success();
  logger.fine(size + "String_Node_Str");
  for (  Node baseNode : allNodes) {
    size-=1;
    if (size % 10 == 0) {
      tx.success();
      tx.close();
      tx=graphDb.beginTx();
    }
    if (size % 100000 == 0) {
      logger.info(size + "String_Node_Str");
    }
    logger.fine("String_Node_Str" + baseNode.getProperty(NodeProperties.IRI));
    if (!baseNode.hasRelationship(IS_EQUIVALENT) && !baseNode.hasRelationship(SAME_AS)) {
      markAsCliqueLeader(baseNode);
    }
 else {
      List<Node> clique=new ArrayList<Node>();
      for (      Node currentNode : graphDb.traversalDescription().relationships(IS_EQUIVALENT,Direction.BOTH).relationships(SAME_AS,Direction.BOTH).uniqueness(Uniqueness.NODE_GLOBAL).traverse(baseNode).nodes()) {
        clique.add(currentNode);
      }
      if (!hasLeader(clique)) {
        Node leader=electCliqueLeader(clique,prefixLeaderPriority);
        markAsCliqueLeader(leader);
        clique.remove(leader);
        markLeaderEdges(leader);
        moveEdgesToLeader(leader,clique);
        ensureLabel(leader,clique);
      }
    }
  }
  tx.success();
}
Program: 32322
Project: 32322
Buggy source:
private Node filterByIri(List<Node> clique,List<String> leaderPriorityIri){
  List<Node> filteredByIriNodes=new ArrayList<Node>();
  if (!leaderPriorityIri.isEmpty()) {
    String iriPriority=leaderPriorityIri.get(0);
    for (    Node n : clique) {
      Optional<String> iri=GraphUtil.getProperty(n,NodeProperties.IRI,String.class);
      if (iri.isPresent() && iri.get().contains(iriPriority)) {
        filteredByIriNodes.add(n);
      }
    }
    if (filteredByIriNodes.isEmpty()) {
      filterByIri(clique,leaderPriorityIri.subList(1,leaderPriorityIri.size()));
    }
  }
  if (filteredByIriNodes.isEmpty()) {
    filteredByIriNodes=clique;
  }
  Collections.sort(filteredByIriNodes,new Comparator<Node>(){
    @Override public int compare(    Node node1,    Node node2){
      Optional<String> iri1=GraphUtil.getProperty(node1,NodeProperties.IRI,String.class);
      Optional<String> iri2=GraphUtil.getProperty(node2,NodeProperties.IRI,String.class);
      return iri1.get().compareTo(iri2.get());
    }
  }
);
  return filteredByIriNodes.get(0);
}

Fixed version (ground truth):
private Node filterByIri(List<Node> clique,List<String> leaderPriorityIri){
  List<Node> filteredByIriNodes=new ArrayList<Node>();
  if (!leaderPriorityIri.isEmpty()) {
    String iriPriority=leaderPriorityIri.get(0);
    for (    Node n : clique) {
      Optional<String> iri=GraphUtil.getProperty(n,NodeProperties.IRI,String.class);
      if (iri.isPresent() && iri.get().contains(iriPriority)) {
        filteredByIriNodes.add(n);
      }
    }
    if (filteredByIriNodes.isEmpty()) {
      filterByIri(clique,leaderPriorityIri.subList(1,leaderPriorityIri.size()));
    }
  }
  if (filteredByIriNodes.isEmpty()) {
    filteredByIriNodes=clique;
  }
  Collections.sort(filteredByIriNodes,new Comparator<Node>(){
    @Override public int compare(    Node node1,    Node node2){
      Optional<String> iri1=GraphUtil.getProperty(node1,NodeProperties.IRI,String.class);
      Optional<String> iri2=GraphUtil.getProperty(node2,NodeProperties.IRI,String.class);
      return iri1.get().compareTo(iri2.get());
    }
  }
);
  List<Node> filteredByIriNodesWithoutAnonymousNodes=new ArrayList<Node>();
  for (  Node n : filteredByIriNodes) {
    if (!n.hasLabel(OwlLabels.OWL_ANONYMOUS)) {
      filteredByIriNodesWithoutAnonymousNodes.add(n);
    }
  }
  if (filteredByIriNodesWithoutAnonymousNodes.isEmpty()) {
    return filteredByIriNodes.get(0);
  }
 else {
    return filteredByIriNodesWithoutAnonymousNodes.get(0);
  }
}
Program: 32323
Project: 32323
Buggy source:
@Override public String lookup(String key){
  Collection<String> resolvedRelationshipTypes=transform(valueMap.get(key),new Function<Object,String>(){
    @Override public String apply(    Object input){
      Optional<String> iri=curieUtil.getIri(input.toString());
      if (iri.isPresent()) {
        return GraphUtil.getFragment(iri.get());
      }
 else {
        return input.toString();
      }
    }
  }
);
  return on('|').join(resolvedRelationshipTypes);
}

Fixed version (ground truth):
@Override public String lookup(String key){
  Collection<String> resolvedRelationshipTypes=transform(valueMap.get(key),new Function<Object,String>(){
    @Override public String apply(    Object input){
      if (input.toString().matches("String_Node_Str")) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      Optional<String> iri=curieUtil.getIri(input.toString());
      if (iri.isPresent()) {
        return GraphUtil.getFragment(iri.get());
      }
 else {
        return input.toString();
      }
    }
  }
);
  return on('|').join(resolvedRelationshipTypes);
}
Program: 32324
Project: 32324
Buggy source:
@Override public String apply(Object input){
  Optional<String> iri=curieUtil.getIri(input.toString());
  if (iri.isPresent()) {
    return GraphUtil.getFragment(iri.get());
  }
 else {
    return input.toString();
  }
}

Fixed version (ground truth):
@Override public String apply(Object input){
  if (input.toString().matches("String_Node_Str")) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  Optional<String> iri=curieUtil.getIri(input.toString());
  if (iri.isPresent()) {
    return GraphUtil.getFragment(iri.get());
  }
 else {
    return input.toString();
  }
}
Program: 32325
Project: 32325
Buggy source:
String substituteRelationships(String query,final Multimap<String,Object> valueMap){
  StrSubstitutor substitutor=new StrSubstitutor(new StrLookup<String>(){
    @Override public String lookup(    String key){
      Collection<String> resolvedRelationshipTypes=transform(valueMap.get(key),new Function<Object,String>(){
        @Override public String apply(        Object input){
          Optional<String> iri=curieUtil.getIri(input.toString());
          if (iri.isPresent()) {
            return GraphUtil.getFragment(iri.get());
          }
 else {
            return input.toString();
          }
        }
      }
);
      return on('|').join(resolvedRelationshipTypes);
    }
  }
);
  return substitutor.replace(query);
}

Fixed version (ground truth):
String substituteRelationships(String query,final Multimap<String,Object> valueMap){
  StrSubstitutor substitutor=new StrSubstitutor(new StrLookup<String>(){
    @Override public String lookup(    String key){
      Collection<String> resolvedRelationshipTypes=transform(valueMap.get(key),new Function<Object,String>(){
        @Override public String apply(        Object input){
          if (input.toString().matches("String_Node_Str")) {
            throw new IllegalArgumentException("String_Node_Str");
          }
          Optional<String> iri=curieUtil.getIri(input.toString());
          if (iri.isPresent()) {
            return GraphUtil.getFragment(iri.get());
          }
 else {
            return input.toString();
          }
        }
      }
);
      return on('|').join(resolvedRelationshipTypes);
    }
  }
);
  return substitutor.replace(query);
}