nus-yam/ex-repair huggingface dataset:
Program: 10745
Project: 10745
Buggy source:
private void startKms() throws IOException {
  if (testDir != null) {
    File logFile=new File(testDir + testClassName,testMethodName + "String_Node_Str");
    KurentoServicesTestHelper.setServerLogFilePath(logFile);
    log.debug("String_Node_Str",logFile.getAbsolutePath());
    if (isKmsRemote) {
      remoteKms.runAndWaitCommand("String_Node_Str","String_Node_Str",remoteKms.getTmpFolder() + "String_Node_Str" + "String_Node_Str"+ remoteKms.getTmpFolder()+ "String_Node_Str");
    }
 else {
      Shell.runAndWait("String_Node_Str","String_Node_Str",workspace + "String_Node_Str" + logFile.getAbsolutePath()+ "String_Node_Str");
    }
  }
 else {
    if (isKmsRemote) {
      remoteKms.execCommand("String_Node_Str","String_Node_Str",remoteKms.getTmpFolder() + "String_Node_Str" + "String_Node_Str");
    }
 else {
      Shell.run("String_Node_Str","String_Node_Str",workspace + "String_Node_Str");
    }
  }
  log.info("String_Node_Str" + this.wsUri);
}

Fixed version (ground truth):
private void startKms() throws IOException {
  if (testDir != null) {
    File logFile=new File(testDir + testClassName,testMethodName + "String_Node_Str");
    KurentoServicesTestHelper.setServerLogFilePath(logFile);
    log.debug("String_Node_Str",logFile.getAbsolutePath());
    if (isKmsRemote) {
      remoteKms.runAndWaitCommand("String_Node_Str","String_Node_Str",remoteKms.getTmpFolder() + "String_Node_Str" + "String_Node_Str"+ remoteKms.getTmpFolder()+ "String_Node_Str");
    }
 else {
      Shell.runAndWait("String_Node_Str","String_Node_Str",workspace + "String_Node_Str" + logFile.getAbsolutePath()+ "String_Node_Str");
    }
  }
 else {
    if (isKmsRemote) {
      remoteKms.execCommand("String_Node_Str","String_Node_Str",remoteKms.getTmpFolder() + "String_Node_Str" + "String_Node_Str");
    }
 else {
      Shell.run("String_Node_Str","String_Node_Str",workspace + "String_Node_Str" + workspace+ "String_Node_Str");
    }
  }
  log.info("String_Node_Str" + this.wsUri);
}
Program: 10746
Project: 10746
Buggy source:
public void addBrowser(String id,BrowserClient browser){
  if (browser.getNumInstances() > 0) {
    for (int i=0; i < browser.getNumInstances(); i++) {
      if (browser.getBrowserPerInstance() > 1) {
        for (int j=0; j < browser.getBrowserPerInstance(); j++) {
          String browserId=(browser.getNumInstances() == 1) ? id + j : id + i + "String_Node_Str"+ j;
          addBrowserInstance(browserId,new BrowserClient(browser.getBuilder()));
        }
      }
 else {
        addBrowserInstance(id + i,new BrowserClient(browser.getBuilder()));
      }
    }
  }
 else {
    addBrowserInstance(id,browser);
  }
}

Fixed version (ground truth):
public void addBrowser(String id,BrowserClient browser){
  if (browser.getNumInstances() > 0) {
    for (int i=0; i < browser.getNumInstances(); i++) {
      if (browser.getBrowserPerInstance() > 1) {
        for (int j=0; j < browser.getBrowserPerInstance(); j++) {
          String browserId=id + i + "String_Node_Str"+ j;
          addBrowserInstance(browserId,new BrowserClient(browser.getBuilder()));
        }
      }
 else {
        addBrowserInstance(id + i,new BrowserClient(browser.getBuilder()));
      }
    }
  }
 else {
    addBrowserInstance(id,browser);
  }
}
Program: 10747
Project: 10747
Buggy source:
public void stopGrid(){
  try {
    if (hub != null) {
      hub.stop();
      hubStarted=false;
    }
    if (nodes != null) {
      for (      GridNode node : nodes.values()) {
        stopNode(node);
      }
    }
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void stopGrid(){
  try {
    if (hub != null) {
      hub.stop();
      hubStarted=false;
    }
    if (nodes != null) {
      for (      GridNode node : nodes.values()) {
        stopNode(node);
      }
    }
    nodes.clear();
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
Program: 10749
Project: 10749
Buggy source:
public void setTransportId(String transportId){
  this.transportId=transportId;
  disablePrevPingWatchdog();
  if (pingWachdog) {
    log.info("String_Node_Str" + "String_Node_Str" + "String_Node_Str",transportId,sessionId,NUM_NO_PINGS_TO_CLOSE * pingInterval);
    activateSessionCloser();
  }
}

Fixed version (ground truth):
public void setTransportId(String transportId){
  this.transportId=transportId;
  disablePrevPingWatchdog();
  if (pingWachdog) {
    if (pingInterval != -1) {
      log.info("String_Node_Str" + "String_Node_Str" + "String_Node_Str",transportId,sessionId,NUM_NO_PINGS_TO_CLOSE * pingInterval);
      activateSessionCloser();
    }
  }
}
Program: 10751
Project: 10751
Buggy source:
private void closeClient(){
  if (client != null) {
    log.debug("String_Node_Str",label);
    try {
      client.stop();
      client.destroy();
      execService.shutdown();
    }
 catch (    Exception e) {
      log.debug("String_Node_Str",label,e);
    }
    execService=null;
    client=null;
  }
}

Fixed version (ground truth):
private void closeClient(){
  if (client != null) {
    log.debug("String_Node_Str",label);
    try {
      client.stop();
      client.destroy();
    }
 catch (    Exception e) {
      log.debug("String_Node_Str",label,e.getMessage());
    }
    client=null;
  }
  if (execService != null) {
    try {
      execService.shutdown();
    }
 catch (    Exception e) {
      log.debug("String_Node_Str",label,e.getMessage());
    }
    execService=null;
  }
}
Program: 10752
Project: 10752
Buggy source:
private void publishWebSocketEndpoint(WebSocketHandlerRegistry wsHandlerRegistry,JsonRpcHandler<?> handler,List<String> paths){
  ProtocolManager protocolManager=(ProtocolManager)ctx.getBean("String_Node_Str",handler);
  JsonRpcWebSocketHandler wsHandler=new JsonRpcWebSocketHandler(protocolManager);
  protocolManager.setPingWachdog(handler.isPingWachdog());
  for (  String path : paths) {
    WebSocketHandlerRegistration registration=wsHandlerRegistry.addHandler(wsHandler,path);
    if (handler.isSockJSEnabled()) {
      registration.withSockJS();
    }
    if (handler.getLabel() != null) {
      wsHandler.setLabel(handler.getLabel());
    }
  }
}

Fixed version (ground truth):
private void publishWebSocketEndpoint(WebSocketHandlerRegistry wsHandlerRegistry,JsonRpcHandler<?> handler,List<String> paths){
  ProtocolManager protocolManager=(ProtocolManager)ctx.getBean("String_Node_Str",handler);
  JsonRpcWebSocketHandler wsHandler=new JsonRpcWebSocketHandler(protocolManager);
  protocolManager.setPingWachdog(handler.isPingWatchdog());
  for (  String path : paths) {
    WebSocketHandlerRegistration registration=wsHandlerRegistry.addHandler(wsHandler,path);
    if (handler.isSockJSEnabled()) {
      registration.withSockJS();
    }
    if (handler.getLabel() != null) {
      wsHandler.setLabel(handler.getLabel());
    }
  }
}
Program: 10753
Project: 10753
Buggy source:
@Override public String toString(){
  String out="String_Node_Str";
  Map<String,Integer> browsers=new HashMap<>();
  for (  String key : browserMap.keySet()) {
    String browser=getBrowserType(key).toString();
    String version=getBrowserVersion(key);
    String platform=getPlatform(key).toString();
    if (version != null) {
      browser+=version;
    }
    if (platform != null) {
      browser+=platform;
    }
    if (browsers.containsKey(browser)) {
      int newCount=browsers.get(browser) + 1;
      browsers.put(browser,newCount);
    }
 else {
      browsers.put(browser,1);
    }
  }
  for (  String browser : browsers.keySet()) {
    int count=browsers.get(browser);
    if (!out.isEmpty()) {
      out+="String_Node_Str";
    }
    if (count > 1) {
      out+=count + "String_Node_Str";
    }
    out+=browser;
  }
  return out;
}

Fixed version (ground truth):
@Override public String toString(){
  String out="String_Node_Str";
  Map<String,Integer> browsers=new HashMap<>();
  for (  String key : browserMap.keySet()) {
    String browser=getBrowserType(key).toString();
    String version=getBrowserVersion(key);
    Platform platform=getPlatform(key);
    if (version != null) {
      browser+=version;
    }
    if (platform != null) {
      browser+=platform;
    }
    if (browsers.containsKey(browser)) {
      int newCount=browsers.get(browser) + 1;
      browsers.put(browser,newCount);
    }
 else {
      browsers.put(browser,1);
    }
  }
  for (  String browser : browsers.keySet()) {
    int count=browsers.get(browser);
    if (!out.isEmpty()) {
      out+="String_Node_Str";
    }
    if (count > 1) {
      out+=count + "String_Node_Str";
    }
    out+=browser;
  }
  return out;
}
Program: 10754
Project: 10754
Buggy source:
protected void handleReconnectDisconnection(final int statusCode,final String closeReason){
  if (!clientClose) {
    reconnecting=true;
    execService.execute(new Runnable(){
      @Override public void run(){
        try {
          connectIfNecessary();
          reconnecting=false;
        }
 catch (        KurentoException e) {
          handlerManager.afterConnectionClosed(session,closeReason);
          log.debug("String_Node_Str",label,closeReason);
          wsSession=null;
          if (connectionListener != null) {
            connectionListener.disconnected();
          }
        }
catch (        IOException e) {
          log.warn("String_Node_Str",label,url,e);
        }
      }
    }
);
  }
 else {
    handlerManager.afterConnectionClosed(session,closeReason);
    if (connectionListener != null) {
      connectionListener.disconnected();
    }
  }
}

Fixed version (ground truth):
protected void handleReconnectDisconnection(final int statusCode,final String closeReason){
  if (!clientClose) {
    reconnecting=true;
    if (execService == null || execService.isShutdown() || execService.isTerminated()) {
      execService=Executors.newFixedThreadPool(10,threadFactory);
    }
    execService.execute(new Runnable(){
      @Override public void run(){
        try {
          connectIfNecessary();
          reconnecting=false;
        }
 catch (        KurentoException e) {
          handlerManager.afterConnectionClosed(session,closeReason);
          log.debug("String_Node_Str",label,closeReason);
          wsSession=null;
          if (connectionListener != null) {
            connectionListener.disconnected();
          }
        }
catch (        IOException e) {
          log.warn("String_Node_Str",label,url,e);
        }
      }
    }
);
  }
 else {
    handlerManager.afterConnectionClosed(session,closeReason);
    if (connectionListener != null) {
      connectionListener.disconnected();
    }
  }
}
Program: 10755
Project: 10755
Buggy source:
private void closeClient(){
  if (client != null) {
    log.debug("String_Node_Str",label);
    try {
      client.stop();
      client.destroy();
      execService.shutdown();
    }
 catch (    Exception e1) {
      log.debug("String_Node_Str",label);
    }
    client=null;
  }
}

Fixed version (ground truth):
private void closeClient(){
  if (client != null) {
    log.debug("String_Node_Str",label);
    try {
      client.stop();
      client.destroy();
      execService.shutdown();
    }
 catch (    Exception e) {
      log.debug("String_Node_Str",label,e);
    }
    execService=null;
    client=null;
  }
}
Program: 10756
Project: 10756
Buggy source:
@Test public void test() throws IOException, InterruptedException {
  log.info("String_Node_Str");
  JsonRpcClient client=createJsonRpcClient("String_Node_Str",new JsonRpcWSConnectionListener(){
    @Override public void connected(){
    }
    @Override public void connectionFailed(){
      System.out.println("String_Node_Str");
    }
    @Override public void disconnected(){
      System.out.println("String_Node_Str");
    }
  }
);
  client.setHeartbeatInterval(500);
  client.enableHeartbeat();
  String result=client.sendRequest("String_Node_Str","String_Node_Str",String.class);
  log.info("String_Node_Str" + result);
  Assert.assertEquals(result,"String_Node_Str");
  Thread.sleep(2000);
  log.info("String_Node_Str");
  client.disableHeartbeat();
  Thread.sleep(50000);
  log.info("String_Node_Str");
}

Fixed version (ground truth):
@Test public void test() throws IOException, InterruptedException {
  log.info("String_Node_Str");
  JsonRpcClient client=createJsonRpcClient("String_Node_Str",new JsonRpcWSConnectionListener(){
    @Override public void connected(){
    }
    @Override public void connectionFailed(){
      System.out.println("String_Node_Str");
    }
    @Override public void disconnected(){
      System.out.println("String_Node_Str");
    }
  }
);
  client.setHeartbeatInterval(500);
  client.enableHeartbeat();
  String result=client.sendRequest("String_Node_Str","String_Node_Str",String.class);
  log.info("String_Node_Str" + result);
  Assert.assertEquals(result,"String_Node_Str");
  Thread.sleep(20000);
  log.info("String_Node_Str");
  client.disableHeartbeat();
  Thread.sleep(30000);
  log.info("String_Node_Str");
  client.enableHeartbeat();
  Thread.sleep(30000);
  log.info("String_Node_Str");
}
Program: 10757
Project: 10757
Buggy source:
@Override public void closeNativeSession(){
  throw new UnsupportedOperationException();
}

Fixed version (ground truth):
@Override public void closeNativeSession(String reason){
  throw new UnsupportedOperationException();
}
Program: 10758
Project: 10758
Buggy source:
public void removeSession(ServerSession session){
  sessions.remove(session.getSessionId());
}

Fixed version (ground truth):
public void removeSession(ServerSession session){
  log.info("String_Node_Str",session.getTransportId());
  sessions.remove(session.getTransportId());
}
Program: 10759
Project: 10759
Buggy source:
private void activateSessionCloser(){
  if (lastTask != null) {
    lastTask.cancel(false);
  }
  lastTask=taskScheduler.schedule(closeSessionTask,new Date(System.currentTimeMillis() + (NUM_NO_PINGS_TO_CLOSE * pingInterval)));
}

Fixed version (ground truth):
private void activateSessionCloser(){
  disablePingWatchdog();
  lastTask=taskScheduler.schedule(closeSessionTask,new Date(System.currentTimeMillis() + (NUM_NO_PINGS_TO_CLOSE * pingInterval)));
}
Program: 10760
Project: 10760
Buggy source:
private PingWatchdogSession getOrCreatePingSession(String transportId){
  PingWatchdogSession session=sessions.get(transportId);
  if (session == null) {
    session=new PingWatchdogSession(transportId);
    sessions.put(transportId,session);
  }
  return session;
}

Fixed version (ground truth):
private synchronized PingWatchdogSession getOrCreatePingSession(String transportId){
  PingWatchdogSession session=sessions.get(transportId);
  if (session == null) {
    log.info("String_Node_Str",transportId);
    session=new PingWatchdogSession(transportId);
    sessions.put(transportId,session);
  }
  return session;
}
Program: 10761
Project: 10761
Buggy source:
public void closeSessionIfTimeout(final String transportId,final String reason){
  final ServerSession session=sessionsManager.getByTransportId(transportId);
  if (session != null) {
    log.info(label + "String_Node_Str",session.getSessionId(),transportId);
    try {
      ScheduledFuture<?> lastStartedTimerFuture=taskScheduler.schedule(new Runnable(){
        @Override public void run(){
          closeSession(session,reason);
        }
      }
,new Date(System.currentTimeMillis() + session.getReconnectionTimeoutInMillis()));
      session.setCloseTimerTask(lastStartedTimerFuture);
    }
 catch (    TaskRejectedException e) {
      log.warn(label + "String_Node_Str" + "String_Node_Str",session.getSessionId(),transportId);
    }
  }
}

Fixed version (ground truth):
public void closeSessionIfTimeout(final String transportId,final String reason){
  final ServerSession session=sessionsManager.getByTransportId(transportId);
  if (session == null) {
    log.warn("String_Node_Str",label,transportId);
  }
 else {
    try {
      Date closeTime=new Date(System.currentTimeMillis() + session.getReconnectionTimeoutInMillis());
      log.info(label + "String_Node_Str",session.getSessionId(),transportId,format.format(closeTime));
      ScheduledFuture<?> lastStartedTimerFuture=taskScheduler.schedule(new Runnable(){
        @Override public void run(){
          closeSession(session,reason);
        }
      }
,closeTime);
      session.setCloseTimerTask(lastStartedTimerFuture);
      pingWachdogManager.disablePingWatchdogForSession(transportId);
    }
 catch (    TaskRejectedException e) {
      log.warn(label + "String_Node_Str" + "String_Node_Str",session.getSessionId(),transportId);
    }
  }
}
Program: 10762
Project: 10762
Buggy source:
private void processReconnectMessage(ServerSessionFactory factory,Request<JsonElement> request,ResponseSender responseSender,String transportId) throws IOException {
  String sessionId=request.getSessionId();
  if (sessionId == null) {
    responseSender.sendResponse(new Response<>(request.getId(),new ResponseError(99999,"String_Node_Str")));
  }
 else {
    ServerSession session=sessionsManager.get(sessionId);
    if (session != null) {
      String oldTransportId=session.getTransportId();
      session.setTransportId(transportId);
      factory.updateSessionOnReconnection(session);
      sessionsManager.updateTransportId(session,oldTransportId);
      cancelCloseTimer(session);
      responseSender.sendResponse(new Response<>(sessionId,request.getId(),RECONNECTION_SUCCESSFUL));
    }
 else {
      responseSender.sendResponse(new Response<>(request.getId(),new ResponseError(99999,RECONNECTION_ERROR)));
    }
  }
}

Fixed version (ground truth):
private void processReconnectMessage(ServerSessionFactory factory,Request<JsonElement> request,ResponseSender responseSender,String transportId) throws IOException {
  String sessionId=request.getSessionId();
  if (sessionId == null) {
    ServerSession session=getSession(factory,transportId,request);
    responseSender.sendResponse(new Response<String>(session.getSessionId(),request.getId(),"String_Node_Str"));
  }
 else {
    ServerSession session=sessionsManager.get(sessionId);
    if (session != null) {
      String oldTransportId=session.getTransportId();
      session.setTransportId(transportId);
      factory.updateSessionOnReconnection(session);
      pingWachdogManager.updateTransportId(transportId,oldTransportId);
      sessionsManager.updateTransportId(session,oldTransportId);
      cancelCloseTimer(session);
      responseSender.sendResponse(new Response<>(sessionId,request.getId(),RECONNECTION_SUCCESSFUL));
    }
 else {
      responseSender.sendResponse(new Response<>(request.getId(),new ResponseError(99999,RECONNECTION_ERROR)));
    }
  }
}
Program: 10763
Project: 10763
Buggy source:
@PostConstruct private void postConstruct(){
  NativeSessionCloser nativeSessionCloser=new NativeSessionCloser(){
    @Override public void closeSession(    String transportId){
      ServerSession serverSession=sessionsManager.getByTransportId(transportId);
      if (serverSession != null) {
        serverSession.closeNativeSession();
      }
 else {
        log.warn("String_Node_Str");
      }
    }
  }
;
  this.pingWachdogManager=new PingWatchdogManager(taskScheduler,nativeSessionCloser);
}

Fixed version (ground truth):
@PostConstruct private void postConstruct(){
  NativeSessionCloser nativeSessionCloser=new NativeSessionCloser(){
    @Override public void closeSession(    String transportId){
      ServerSession serverSession=sessionsManager.getByTransportId(transportId);
      if (serverSession != null) {
        serverSession.closeNativeSession("String_Node_Str");
      }
 else {
        log.warn("String_Node_Str");
      }
    }
  }
;
  this.pingWachdogManager=new PingWatchdogManager(taskScheduler,nativeSessionCloser);
}
Program: 10764
Project: 10764
Buggy source:
public abstract void closeNativeSession();

Fixed version (ground truth):
public abstract void closeNativeSession(String reason);
Program: 10765
Project: 10765
Buggy source:
@SuppressWarnings("String_Node_Str") public synchronized <T>T getById(String objectRef,Class<T> clazz){
  RemoteObject remoteObject=(RemoteObject)this.getObject(objectRef);
  if (remoteObject == null) {
    remoteObject=new RemoteObject(objectRef,clazz.getSimpleName(),this);
    RemoteObjectInvocationHandler.newProxy(remoteObject,this,clazz);
  }
  return (T)remoteObject.getKurentoObject();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public synchronized <T>T getById(String objectRef,Class<T> clazz){
  RemoteObject remoteObject=(RemoteObject)this.getObject(objectRef);
  if (remoteObject == null) {
    clazz=obtainConcreteClass(objectRef,clazz);
    remoteObject=new RemoteObject(objectRef,clazz.getSimpleName(),this);
    RemoteObjectInvocationHandler.newProxy(remoteObject,this,clazz);
  }
  return (T)remoteObject.getKurentoObject();
}
Program: 10766
Project: 10766
Buggy source:
@SuppressWarnings("String_Node_Str") public T build(Transaction transaction){
  RemoteObject remoteObject=manager.create(clazz.getSimpleName(),props,transaction);
  return (T)RemoteObjectInvocationHandler.newProxy(remoteObject,manager,clazz);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public T build(Transaction transaction){
  RemoteObject remoteObject=manager.createWithKurentoObject(clazz,props,transaction);
  return (T)remoteObject.getKurentoObject();
}
Program: 10767
Project: 10767
Buggy source:
public ServerManager getServerManager(){
  return manager.getOrCreateObject("String_Node_Str",ServerManager.class);
}

Fixed version (ground truth):
public ServerManager getServerManager(){
  return getById("String_Node_Str",ServerManager.class);
}
Program: 10768
Project: 10768
Buggy source:
private Object unflattenRemoteObject(Type type,String value,ObjectRefsManager manager){
  Object remoteObject=manager.getObject(value);
  if (remoteObject == null) {
    if (manager instanceof RomManager) {
      RomManager clientManager=(RomManager)manager;
      RemoteObject newRemoteObject=new RemoteObject(value,((Class<?>)type).getSimpleName(),clientManager);
      clientManager.registerObject(value,newRemoteObject);
      return newRemoteObject;
    }
    throw new ProtocolException("String_Node_Str" + value + "String_Node_Str");
  }
 else   if (remoteObject instanceof RemoteObject) {
    Object wrapper=((RemoteObject)remoteObject).getKurentoObject();
    return (wrapper != null) ? wrapper : remoteObject;
  }
 else {
    return remoteObject;
  }
}

Fixed version (ground truth):
private Object unflattenRemoteObject(Type type,String id,ObjectRefsManager manager){
  Object remoteObject=manager.getObject(id);
  if (remoteObject == null) {
    if (manager instanceof RomManager) {
      RomManager clientManager=(RomManager)manager;
      return clientManager.getById(id,(Class<?>)type);
    }
    throw new ProtocolException("String_Node_Str" + id + "String_Node_Str");
  }
 else   if (remoteObject instanceof RemoteObject) {
    Object wrapper=((RemoteObject)remoteObject).getKurentoObject();
    return wrapper != null ? wrapper : remoteObject;
  }
 else {
    return remoteObject;
  }
}
Program: 10770
Project: 10770
Buggy source:
@Test public void testObjectCreationEvents() throws InterruptedException {
  ServerManager server=kurentoClient.getServerManager();
  final Exchanger<MediaObject> exchanger=new Exchanger<>();
  server.addObjectCreatedListener(new EventListener<ObjectCreatedEvent>(){
    @Override public void onEvent(    ObjectCreatedEvent event){
      try {
        exchanger.exchange(event.getObject());
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
);
  MediaPipeline pipeline=kurentoClient.createMediaPipeline();
  try {
    MediaObject eventObject=exchanger.exchange(null,500,TimeUnit.SECONDS);
    System.out.println("String_Node_Str" + pipeline);
    System.out.println("String_Node_Str" + eventObject);
    assertThat(pipeline,IsSame.sameInstance(eventObject));
  }
 catch (  TimeoutException e) {
    fail(ObjectCreatedEvent.class.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
@Test public void testObjectCreationEvents() throws InterruptedException {
  ServerManager server=kurentoClient.getServerManager();
  final Exchanger<MediaObject> exchanger=new Exchanger<>();
  server.addObjectCreatedListener(new EventListener<ObjectCreatedEvent>(){
    @Override public void onEvent(    ObjectCreatedEvent event){
      try {
        exchanger.exchange(event.getObject());
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
);
  MediaPipeline pipeline=kurentoClient.createMediaPipeline();
  try {
    MediaObject eventObject=exchanger.exchange(null,10,TimeUnit.SECONDS);
    System.out.println("String_Node_Str" + pipeline);
    System.out.println("String_Node_Str" + eventObject);
    assertThat(pipeline,IsSame.sameInstance(eventObject));
  }
 catch (  TimeoutException e) {
    fail(ObjectCreatedEvent.class.getName() + "String_Node_Str");
  }
}
Program: 10773
Project: 10773
Buggy source:
private <P,R>Response<R> sendRequestWebSocket(Request<P> request,Class<R> resultClass){
  Future<Response<JsonElement>> responseFuture=null;
  if (request.getId() != null) {
    responseFuture=pendingRequests.prepareResponse(request.getId());
  }
  try {
synchronized (wsSession) {
      wsSession.sendMessage(new TextMessage(JsonUtils.toJson(request)));
    }
  }
 catch (  Exception e) {
    throw new KurentoException("String_Node_Str" + JsonUtils.toJson(request) + "String_Node_Str"+ wsSession.getId()+ "String_Node_Str",e);
  }
  if (responseFuture == null) {
    return null;
  }
  Response<JsonElement> responseJsonObject;
  try {
    responseJsonObject=responseFuture.get();
  }
 catch (  InterruptedException e) {
    throw new JsonRpcException("String_Node_Str",e);
  }
catch (  ExecutionException e) {
    throw new JsonRpcException("String_Node_Str",e);
  }
  return MessageUtils.convertResponse(responseJsonObject,resultClass);
}

Fixed version (ground truth):
private <P,R>Response<R> sendRequestWebSocket(Request<P> request,Class<R> resultClass){
  Future<Response<JsonElement>> responseFuture=null;
  if (request.getId() != null) {
    responseFuture=pendingRequests.prepareResponse(request.getId());
  }
  try {
synchronized (wsSession) {
      wsSession.sendMessage(new TextMessage(JsonUtils.toJson(request)));
    }
  }
 catch (  Exception e) {
    throw new KurentoException("String_Node_Str" + JsonUtils.toJson(request) + "String_Node_Str"+ wsSession.getId()+ "String_Node_Str",e);
  }
  if (responseFuture == null) {
    return null;
  }
  Response<JsonElement> responseJsonObject;
  try {
    responseJsonObject=responseFuture.get(JsonRpcClientWebSocket.TIMEOUT,TimeUnit.MILLISECONDS);
  }
 catch (  InterruptedException e) {
    throw new JsonRpcException("String_Node_Str",e);
  }
catch (  ExecutionException e) {
    throw new JsonRpcException("String_Node_Str",e);
  }
catch (  TimeoutException e) {
    throw new TransportException("String_Node_Str" + JsonRpcClientWebSocket.TIMEOUT + "String_Node_Str"+ request.getId(),e);
  }
  return MessageUtils.convertResponse(responseJsonObject,resultClass);
}
Program: 10774
Project: 10774
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) protected void propagateEventTo(Object object,Class<? extends Event> eventClass,Props data,EventListener<?> listener){
  try {
    Constructor<?> constructor=eventClass.getConstructors()[0];
    data.add("String_Node_Str",object);
    Object[] params=ParamsFlattener.getInstance().unflattenParams(constructor.getParameterAnnotations(),constructor.getGenericParameterTypes(),data,manager);
    Event e=(Event)constructor.newInstance(params);
    ((EventListener)listener).onEvent(e);
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str" + eventClass.getSimpleName() + "String_Node_Str"+ data+ "String_Node_Str",e);
  }
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) protected void propagateEventTo(Object object,Class<? extends Event> eventClass,Props data,EventListener<?> listener){
  try {
    Constructor<?> constructor=eventClass.getConstructors()[0];
    data.add("String_Node_Str",((KurentoObject)object).getId());
    Object[] params=ParamsFlattener.getInstance().unflattenParams(constructor.getParameterAnnotations(),constructor.getGenericParameterTypes(),data,manager);
    Event e=(Event)constructor.newInstance(params);
    ((EventListener)listener).onEvent(e);
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str" + eventClass.getSimpleName() + "String_Node_Str"+ data+ "String_Node_Str",e);
  }
}
Program: 10775
Project: 10775
Buggy source:
private void closeClient(){
  if (client != null) {
    log.debug("String_Node_Str",label);
    try {
      client.stop();
      client.destroy();
    }
 catch (    Exception e1) {
      log.debug("String_Node_Str",label);
    }
    client=null;
  }
}

Fixed version (ground truth):
private void closeClient(){
  if (client != null) {
    log.debug("String_Node_Str",label);
    try {
      client.stop();
      client.destroy();
      execService.shutdown();
    }
 catch (    Exception e1) {
      log.debug("String_Node_Str",label);
    }
    client=null;
  }
}
Program: 10776
Project: 10776
Buggy source:
public Object flattenResult(Object result,RemoteObjectManager manager){
  if (result == null) {
    return null;
  }
 else   if (result instanceof Enum<?>) {
    return result.toString();
  }
 else   if (isPrimitive(result)) {
    return result;
  }
 else   if (result instanceof List<?>) {
    return flattenResultList((List<?>)result,manager);
  }
 else   if (result.getClass().getAnnotation(RemoteClass.class) != null) {
    return extractObjectRefFromRemoteClass(result,manager);
  }
 else {
    return extractResultAsProps(result,manager);
  }
}

Fixed version (ground truth):
public Object flattenResult(Object result,RemoteObjectManager manager){
  if (result == null) {
    return null;
  }
 else   if (result instanceof Enum<?>) {
    return result.toString();
  }
 else   if (isPrimitive(result)) {
    return result;
  }
 else   if (result instanceof List<?>) {
    return flattenResultList((List<?>)result,manager);
  }
 else   if (result instanceof Map<?,?>) {
    return flattenParamsMap((Map<String,?>)result,false);
  }
 else   if (result.getClass().getAnnotation(RemoteClass.class) != null) {
    return extractObjectRefFromRemoteClass(result,manager);
  }
 else {
    return extractResultAsProps(result,manager);
  }
}
Program: 10777
Project: 10777
Buggy source:
public Object unflattenValue(String paramName,Type type,Object value,ObjectRefsManager manager){
  if (type instanceof Class) {
    Class<?> clazz=(Class<?>)type;
    if (isPrimitiveClass(clazz)) {
      return value;
    }
 else     if (clazz.isEnum()) {
      return unflattenEnumConstant(type,value,clazz);
    }
 else {
      if (value instanceof String) {
        return unflattenRemoteObject(type,(String)value,manager);
      }
 else       if (value instanceof Props) {
        Props props=(Props)value;
        Class<?> newClazz=getOrCreateClass(props);
        if (newClazz != null) {
          clazz=newClazz;
        }
        return unflattedComplexType(clazz,props,manager);
      }
 else {
        throw new ProtocolException("String_Node_Str" + type + "String_Node_Str");
      }
    }
  }
 else   if (type instanceof ParameterizedType) {
    ParameterizedType pType=(ParameterizedType)type;
    if (((Class<?>)pType.getRawType()).isAssignableFrom(List.class)) {
      return unflattenList(paramName,(List<?>)value,pType.getActualTypeArguments()[0],manager);
    }
    if (((Class<?>)pType.getRawType()).isAssignableFrom(Map.class)) {
      return unflattenMap(paramName,(Props)value,pType.getActualTypeArguments()[0],manager);
    }
  }
  throw new ProtocolException("String_Node_Str" + type + "String_Node_Str");
}

Fixed version (ground truth):
public Object unflattenValue(String paramName,Type type,Object value,ObjectRefsManager manager){
  if (type instanceof Class) {
    Class<?> clazz=(Class<?>)type;
    if (isPrimitiveClass(clazz)) {
      return value;
    }
 else     if (clazz.isEnum()) {
      return unflattenEnumConstant(type,value,clazz);
    }
 else {
      if (value instanceof String) {
        return unflattenRemoteObject(type,(String)value,manager);
      }
 else       if (value instanceof Props) {
        Props props=(Props)value;
        Class<?> newClazz=getOrCreateClass(props);
        if (newClazz != null) {
          clazz=newClazz;
        }
        return unflattedComplexType(clazz,props,manager);
      }
 else {
        throw new ProtocolException("String_Node_Str" + type + "String_Node_Str");
      }
    }
  }
 else   if (type instanceof ParameterizedType) {
    ParameterizedType pType=(ParameterizedType)type;
    if (((Class<?>)pType.getRawType()).isAssignableFrom(List.class)) {
      return unflattenList(paramName,(List<?>)value,pType.getActualTypeArguments()[0],manager);
    }
    if (((Class<?>)pType.getRawType()).isAssignableFrom(Map.class)) {
      return unflattenMap(paramName,(Props)value,pType.getActualTypeArguments()[1],manager);
    }
  }
  throw new ProtocolException("String_Node_Str" + type + "String_Node_Str");
}
Program: 10778
Project: 10778
Buggy source:
private Object unflattenMap(String paramName,Props value,Type type,ObjectRefsManager manager){
  Map<String,Object> map=new HashMap<String,Object>();
  if (value != null) {
    for (    Prop p : value) {
      map.put(p.getName(),p.getValue());
    }
  }
  return map;
}

Fixed version (ground truth):
private Object unflattenMap(String paramName,Props value,Type type,ObjectRefsManager manager){
  Map<String,Object> map=new HashMap<String,Object>();
  if (value != null) {
    for (    Prop p : value) {
      map.put(p.getName(),unflattenValue(paramName + "String_Node_Str" + p.getName()+ "String_Node_Str",type,p.getValue(),manager));
    }
  }
  return map;
}
Program: 10780
Project: 10780
Buggy source:
@Override public void run(){
  try {
    JsonObject response=sendRequest(METHOD_PING).getAsJsonObject();
    if (!PONG.equals(response.get(PONG_PAYLOAD).getAsString())) {
      stopHeartbeatOnFailure();
    }
  }
 catch (  Exception e) {
    log.warn("String_Node_Str",label,e);
    stopHeartbeatOnFailure();
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    JsonObject response=sendRequest(METHOD_PING).getAsJsonObject();
    if (!PONG.equals(response.get(PONG_PAYLOAD).getAsString())) {
      closeHeartbeatOnFailure();
    }
  }
 catch (  Exception e) {
    log.warn("String_Node_Str",label);
    closeHeartbeatOnFailure();
  }
}
Program: 10781
Project: 10781
Buggy source:
public void disableHeartbeat(){
  this.heartbeating=false;
  heartbeat.cancel(false);
}

Fixed version (ground truth):
public void disableHeartbeat(){
  if (heartbeating) {
    this.heartbeating=false;
    heartbeat.cancel(true);
    scheduler.shutdownNow();
  }
}
Program: 10782
Project: 10782
Buggy source:
public void enableHeartbeat(int interval){
  this.heartbeatInterval=interval;
  heartbeat=scheduler.scheduleAtFixedRate(new Runnable(){
    @Override public void run(){
      try {
        JsonObject response=sendRequest(METHOD_PING).getAsJsonObject();
        if (!PONG.equals(response.get(PONG_PAYLOAD).getAsString())) {
          stopHeartbeatOnFailure();
        }
      }
 catch (      Exception e) {
        log.warn("String_Node_Str",label,e);
        stopHeartbeatOnFailure();
      }
    }
  }
,0,heartbeatInterval,MILLISECONDS);
}

Fixed version (ground truth):
public void enableHeartbeat(int interval){
  this.heartbeating=true;
  this.heartbeatInterval=interval;
  if (scheduler.isShutdown()) {
    scheduler=Executors.newSingleThreadScheduledExecutor();
  }
  heartbeat=scheduler.scheduleAtFixedRate(new Runnable(){
    @Override public void run(){
      try {
        JsonObject response=sendRequest(METHOD_PING).getAsJsonObject();
        if (!PONG.equals(response.get(PONG_PAYLOAD).getAsString())) {
          closeHeartbeatOnFailure();
        }
      }
 catch (      Exception e) {
        log.warn("String_Node_Str",label);
        closeHeartbeatOnFailure();
      }
    }
  }
,0,heartbeatInterval,MILLISECONDS);
}
Program: 10784
Project: 10784
Buggy source:
@Override protected <P2,R2>Response<R2> internalSendRequest(Request<P2> request,Class<R2> resultClass) throws IOException {
  final Object[] response=new Object[1];
  try {
    handlerManager.handleRequest(session,(Request<JsonElement>)request,new ResponseSender(){
      @Override public void sendResponse(      Message message) throws IOException {
        response[0]=message;
      }
    }
);
    Response<R2> response2=(Response<R2>)response[0];
    Object result=response2.getResult();
    if (result == null || resultClass.isAssignableFrom(result.getClass())) {
      return response2;
    }
 else     if (resultClass == JsonElement.class) {
      response2.setResult((R2)JsonUtils.toJsonElement(result));
      return response2;
    }
 else {
      throw new ClassCastException("String_Node_Str" + result + "String_Node_Str"+ resultClass);
    }
  }
 catch (  IOException e) {
    return new Response<R2>(request.getId(),ResponseError.newFromException(e));
  }
}

Fixed version (ground truth):
@Override protected <P2,R2>Response<R2> internalSendRequest(Request<P2> request,Class<R2> resultClass) throws IOException {
  final Object[] response=new Object[1];
  try {
    handlerManager.handleRequest(session,(Request<JsonElement>)request,new ResponseSender(){
      @Override public void sendResponse(      Message message) throws IOException {
        response[0]=message;
      }
      @Override public void sendPingResponse(      Message message) throws IOException {
        sendResponse(message);
      }
    }
);
    Response<R2> response2=(Response<R2>)response[0];
    Object result=response2.getResult();
    if (result == null || resultClass.isAssignableFrom(result.getClass())) {
      return response2;
    }
 else     if (resultClass == JsonElement.class) {
      response2.setResult((R2)JsonUtils.toJsonElement(result));
      return response2;
    }
 else {
      throw new ClassCastException("String_Node_Str" + result + "String_Node_Str"+ resultClass);
    }
  }
 catch (  IOException e) {
    return new Response<R2>(request.getId(),ResponseError.newFromException(e));
  }
}
Program: 10786
Project: 10786
Buggy source:
private <P,R>Response<R> internalSendRequestWebSocket(Request<P> request,Class<R> resultClass) throws IOException {
  connectIfNecessary();
  Future<Response<JsonElement>> responseFuture=null;
  if (request.getId() != null) {
    responseFuture=pendingRequests.prepareResponse(request.getId());
  }
  String jsonMessage=request.toString();
  log.debug("String_Node_Str",label,jsonMessage.trim());
synchronized (wsSession) {
    wsSession.getRemote().sendString(jsonMessage);
  }
  if (responseFuture == null) {
    return null;
  }
  Response<JsonElement> responseJson;
  try {
    responseJson=responseFuture.get(TIMEOUT,TimeUnit.MILLISECONDS);
    log.debug("String_Node_Str",label,responseJson.toString());
    Response<R> response=MessageUtils.convertResponse(responseJson,resultClass);
    if (response.getSessionId() != null) {
      session.setSessionId(response.getSessionId());
    }
    return response;
  }
 catch (  InterruptedException e) {
    throw new KurentoException(label + "String_Node_Str",e);
  }
catch (  ExecutionException e) {
    throw new KurentoException(label + "String_Node_Str",e);
  }
catch (  TimeoutException e) {
    throw new TransportException(label + "String_Node_Str" + TIMEOUT+ "String_Node_Str"+ request.getId(),e);
  }
}

Fixed version (ground truth):
private <P,R>Response<R> internalSendRequestWebSocket(Request<P> request,Class<R> resultClass) throws IOException {
  connectIfNecessary();
  Future<Response<JsonElement>> responseFuture=null;
  if (request.getId() != null) {
    responseFuture=pendingRequests.prepareResponse(request.getId());
  }
  boolean isPing=false;
  String jsonMessage=request.toString();
  if (METHOD_PING.equals(request.getMethod())) {
    isPing=true;
    log.trace("String_Node_Str",label,jsonMessage.trim());
  }
 else {
    log.debug("String_Node_Str",label,jsonMessage.trim());
  }
synchronized (wsSession) {
    wsSession.getRemote().sendString(jsonMessage);
  }
  if (responseFuture == null) {
    return null;
  }
  Response<JsonElement> responseJson;
  try {
    responseJson=responseFuture.get(TIMEOUT,TimeUnit.MILLISECONDS);
    if (isPing) {
      log.trace("String_Node_Str",label,responseJson.toString());
    }
 else {
      log.debug("String_Node_Str",label,responseJson.toString());
    }
    Response<R> response=MessageUtils.convertResponse(responseJson,resultClass);
    if (response.getSessionId() != null) {
      session.setSessionId(response.getSessionId());
    }
    return response;
  }
 catch (  InterruptedException e) {
    throw new KurentoException(label + "String_Node_Str",e);
  }
catch (  ExecutionException e) {
    throw new KurentoException(label + "String_Node_Str",e);
  }
catch (  TimeoutException e) {
    throw new TransportException(label + "String_Node_Str" + TIMEOUT+ "String_Node_Str"+ request.getId(),e);
  }
}
Program: 10787
Project: 10787
Buggy source:
@OnWebSocketConnect public void onConnect(Session session){
  wsSession=session;
  rs=new ResponseSender(){
    @Override public void sendResponse(    Message message) throws IOException {
      String jsonMessage=message.toString();
      log.debug("String_Node_Str",label,jsonMessage);
synchronized (wsSession) {
        wsSession.getRemote().sendString(jsonMessage);
      }
    }
  }
;
  latch.countDown();
  if (connectionListener != null && !reconnecting) {
    connectionListener.connected();
  }
}

Fixed version (ground truth):
@OnWebSocketConnect public void onConnect(Session session){
  wsSession=session;
  rs=new ResponseSender(){
    @Override public void sendResponse(    Message message) throws IOException {
      String jsonMessage=message.toString();
      log.debug("String_Node_Str",label,jsonMessage);
synchronized (wsSession) {
        wsSession.getRemote().sendString(jsonMessage);
      }
    }
    @Override public void sendPingResponse(    Message message) throws IOException {
      String jsonMessage=message.toString();
      log.trace("String_Node_Str",label,jsonMessage);
synchronized (wsSession) {
        wsSession.getRemote().sendString(jsonMessage);
      }
    }
  }
;
  latch.countDown();
  if (connectionListener != null && !reconnecting) {
    connectionListener.connected();
  }
}
Program: 10788
Project: 10788
Buggy source:
@Override public void close() throws IOException {
  if (wsSession != null) {
    clientClose=true;
    wsSession.close();
    client.destroy();
  }
}

Fixed version (ground truth):
@Override public void close() throws IOException {
  if (wsSession != null) {
    log.debug("String_Node_Str",label);
    this.disableHeartbeat();
    clientClose=true;
    wsSession.close();
    this.closeClient();
  }
}
Program: 10789
Project: 10789
Buggy source:
@Override public void handleRequest(HttpServletRequest servletRequest,final HttpServletResponse servletResponse) throws ServletException, IOException {
  String messageJson=getBodyAsString(servletRequest);
  ServerSessionFactory factory=new ServerSessionFactory(){
    @Override public ServerSession createSession(    String sessionId,    Object registerInfo,    SessionsManager sessionsManager){
      return new HttpRequestServerSession(sessionId,registerInfo,sessionsManager,null);
    }
    @Override public void updateSessionOnReconnection(    ServerSession session){
      throw new UnsupportedOperationException();
    }
  }
;
  ResponseSender responseSender=new ResponseSender(){
    @Override public void sendResponse(    Message message) throws IOException {
      servletResponse.getWriter().println(message);
    }
  }
;
  String internalSessionId=null;
  HttpSession session=servletRequest.getSession(false);
  if (session != null) {
    internalSessionId=session.getId();
  }
  protocolManager.processMessage(messageJson,factory,responseSender,internalSessionId);
}

Fixed version (ground truth):
@Override public void handleRequest(HttpServletRequest servletRequest,final HttpServletResponse servletResponse) throws ServletException, IOException {
  String messageJson=getBodyAsString(servletRequest);
  ServerSessionFactory factory=new ServerSessionFactory(){
    @Override public ServerSession createSession(    String sessionId,    Object registerInfo,    SessionsManager sessionsManager){
      return new HttpRequestServerSession(sessionId,registerInfo,sessionsManager,null);
    }
    @Override public void updateSessionOnReconnection(    ServerSession session){
      throw new UnsupportedOperationException();
    }
  }
;
  ResponseSender responseSender=new ResponseSender(){
    @Override public void sendResponse(    Message message) throws IOException {
      servletResponse.getWriter().println(message);
    }
    @Override public void sendPingResponse(    Message message) throws IOException {
      sendResponse(message);
    }
  }
;
  String internalSessionId=null;
  HttpSession session=servletRequest.getSession(false);
  if (session != null) {
    internalSessionId=session.getId();
  }
  protocolManager.processMessage(messageJson,factory,responseSender,internalSessionId);
}
Program: 10790
Project: 10790
Buggy source:
protected void playFileAsLocal(BrowserType browserType,String recordingFile,int playtime,int x,int y,Color... expectedColors) throws InterruptedException {
  BrowserClient browserClient=new BrowserClient.Builder().browserType(browserType).client(Client.WEBRTC).protocol(Protocol.FILE).build();
  browserClient.init();
  String browserkey="String_Node_Str";
  addBrowserClient(browserkey,browserClient);
  getBrowser(browserkey).subscribeEvents("String_Node_Str");
  browserClient.executeScript("String_Node_Str" + VideoTagType.REMOTE.getId() + "String_Node_Str"+ recordingFile+ "String_Node_Str");
  browserClient.executeScript("String_Node_Str" + VideoTagType.REMOTE.getId() + "String_Node_Str");
  makeAssertions(browserkey,"String_Node_Str",browserClient,playtime,x,y,null,expectedColors);
}

Fixed version (ground truth):
protected void playFileAsLocal(BrowserType browserType,String recordingFile,int playtime,int x,int y,Color... expectedColors) throws InterruptedException {
  BrowserClient browserClient=new BrowserClient.Builder().browserType(browserType).client(Client.WEBRTC).protocol(Protocol.FILE).build();
  String browserkey="String_Node_Str";
  addBrowserClient(browserkey,browserClient);
  getBrowser(browserkey).subscribeEvents("String_Node_Str");
  browserClient.executeScript("String_Node_Str" + VideoTagType.REMOTE.getId() + "String_Node_Str"+ recordingFile+ "String_Node_Str");
  browserClient.executeScript("String_Node_Str" + VideoTagType.REMOTE.getId() + "String_Node_Str");
  makeAssertions(browserkey,"String_Node_Str",browserClient,playtime,x,y,null,expectedColors);
}