nus-yam/ex-repair huggingface dataset:
Program: 37387
Project: 37387
Buggy source:
/** 
 * Resume the thread the times as it has been suspended.
 * @param thread the thread reference
 */
public static void resumeThread(ThreadReference thread){
  if (thread == null) {
    return;
  }
  int suspends=thread.suspendCount();
  for (int i=0; i < suspends; i++) {
    thread.resume();
  }
}

Fixed version (ground truth):
/** 
 * Resume the thread the times as it has been suspended.
 * @param thread the thread reference
 */
public static void resumeThread(ThreadReference thread){
  if (thread == null || thread.isCollected()) {
    return;
  }
  try {
    int suspends=thread.suspendCount();
    for (int i=0; i < suspends; i++) {
      thread.resume();
    }
  }
 catch (  ObjectCollectedException ex) {
  }
}
Program: 37388
Project: 37388
Buggy source:
/** 
 * Get the ThreadReference instance by the thread id.
 * @param debugSession the debug session
 * @param threadId the thread id
 * @return the ThreadReference instance
 */
public static ThreadReference getThread(IDebugSession debugSession,long threadId){
  for (  ThreadReference thread : getAllThreadsSafely(debugSession)) {
    if (thread.uniqueID() == threadId) {
      return thread;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Get the ThreadReference instance by the thread id.
 * @param debugSession the debug session
 * @param threadId the thread id
 * @return the ThreadReference instance
 */
public static ThreadReference getThread(IDebugSession debugSession,long threadId){
  for (  ThreadReference thread : getAllThreadsSafely(debugSession)) {
    if (thread.uniqueID() == threadId && !thread.isCollected()) {
      return thread;
    }
  }
  return null;
}
Program: 37389
Project: 37389
Buggy source:
private static CompletableFuture<Location> step(ThreadReference thread,IEventHub eventHub,int stepSize,int stepDepth){
  CompletableFuture<Location> future=new CompletableFuture<Location>();
  StepRequest request=thread.virtualMachine().eventRequestManager().createStepRequest(thread,stepSize,stepDepth);
  eventHub.stepEvents().filter(debugEvent -> request.equals(debugEvent.event.request())).take(1).subscribe(debugEvent -> {
    StepEvent event=(StepEvent)debugEvent.event;
    future.complete(event.location());
    thread.virtualMachine().eventRequestManager().deleteEventRequest(request);
  }
);
  request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  request.addCountFilter(1);
  request.enable();
  thread.resume();
  return future;
}

Fixed version (ground truth):
private static CompletableFuture<Location> step(ThreadReference thread,IEventHub eventHub,int stepSize,int stepDepth){
  CompletableFuture<Location> future=new CompletableFuture<>();
  StepRequest request=thread.virtualMachine().eventRequestManager().createStepRequest(thread,stepSize,stepDepth);
  eventHub.stepEvents().filter(debugEvent -> request.equals(debugEvent.event.request())).take(1).subscribe(debugEvent -> {
    StepEvent event=(StepEvent)debugEvent.event;
    future.complete(event.location());
    thread.virtualMachine().eventRequestManager().deleteEventRequest(request);
  }
);
  request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  request.addCountFilter(1);
  request.enable();
  thread.resume();
  return future;
}
Program: 37390
Project: 37390
Buggy source:
/** 
 * Constructor.
 */
public DebugAdapter(BiConsumer<Events.DebugEvent,Boolean> consumer,IProviderContext providerContext){
  this.eventConsumer=consumer;
  this.providerContext=providerContext;
  this.debugContext=new DebugAdapterContext(this);
  this.requestHandlers=new HashMap<>();
  initialize();
}

Fixed version (ground truth):
/** 
 * Constructor.
 */
public DebugAdapter(BiConsumer<Events.DebugEvent,Boolean> consumer,IProviderContext providerContext){
  eventConsumer=consumer;
  this.providerContext=providerContext;
  debugContext=new DebugAdapterContext(this);
  requestHandlers=new HashMap<>();
  initialize();
}
Program: 37391
Project: 37391
Buggy source:
/** 
 * Send event to DA immediately.
 * @see ProtocolServer#sendEvent(String,Object)
 */
public void sendEvent(Events.DebugEvent event){
  this.eventConsumer.accept(event,false);
}

Fixed version (ground truth):
/** 
 * Send event to DA immediately.
 * @see ProtocolServer#sendEvent(String,Object)
 */
public void sendEvent(Events.DebugEvent event){
  eventConsumer.accept(event,false);
}
Program: 37392
Project: 37392
Buggy source:
@Override public Messages.Response dispatchRequest(Messages.Request request){
  Messages.Response response=new Messages.Response();
  response.request_seq=request.seq;
  response.command=request.command;
  response.success=true;
  Command command=Command.parse(request.command);
  Arguments cmdArgs=JsonUtils.fromJson(request.arguments,command.getArgumentType());
  try {
    List<IDebugRequestHandler> handlers=requestHandlers.get(command);
    if (handlers != null && !handlers.isEmpty()) {
      for (      IDebugRequestHandler handler : handlers) {
        handler.handle(command,cmdArgs,response,this.debugContext);
      }
    }
 else {
      AdapterUtils.setErrorResponse(response,ErrorCode.UNRECOGNIZED_REQUEST_FAILURE,String.format("String_Node_Str",request.command));
    }
  }
 catch (  Exception e) {
    logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
    AdapterUtils.setErrorResponse(response,ErrorCode.UNKNOWN_FAILURE,e.getMessage() != null ? e.getMessage() : e.toString());
  }
  return response;
}

Fixed version (ground truth):
@Override public Messages.Response dispatchRequest(Messages.Request request){
  Messages.Response response=new Messages.Response();
  response.request_seq=request.seq;
  response.command=request.command;
  response.success=true;
  Command command=Command.parse(request.command);
  Arguments cmdArgs=JsonUtils.fromJson(request.arguments,command.getArgumentType());
  try {
    if (debugContext.isVmTerminated()) {
      AdapterUtils.setErrorResponse(response,ErrorCode.VM_TERMINATED,String.format("String_Node_Str",request.command));
      return response;
    }
    List<IDebugRequestHandler> handlers=requestHandlers.get(command);
    if (handlers != null && !handlers.isEmpty()) {
      for (      IDebugRequestHandler handler : handlers) {
        handler.handle(command,cmdArgs,response,debugContext);
      }
    }
 else {
      AdapterUtils.setErrorResponse(response,ErrorCode.UNRECOGNIZED_REQUEST_FAILURE,String.format("String_Node_Str",request.command));
    }
  }
 catch (  Exception e) {
    logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
    AdapterUtils.setErrorResponse(response,ErrorCode.UNKNOWN_FAILURE,e.getMessage() != null ? e.getMessage() : e.toString());
  }
  return response;
}
Program: 37393
Project: 37393
Buggy source:
/** 
 * Send event to DA after the current dispatching request is resolved.
 * @see ProtocolServer#sendEventLater(String,Object)
 */
public void sendEventLater(Events.DebugEvent event){
  this.eventConsumer.accept(event,true);
}

Fixed version (ground truth):
/** 
 * Send event to DA after the current dispatching request is resolved.
 * @see ProtocolServer#sendEventLater(String,Object)
 */
public void sendEventLater(Events.DebugEvent event){
  eventConsumer.accept(event,true);
}
Program: 37395
Project: 37395
Buggy source:
/** 
 * Removes the specified breakpoints from breakpoint manager.
 */
private void removeBreakpointsInternally(String source,IBreakpoint[] breakpoints){
  Map<String,IBreakpoint> breakpointMap=this.sourceToBreakpoints.get(source);
  if (breakpointMap == null || breakpointMap.isEmpty() || breakpoints.length == 0) {
    return;
  }
  for (  IBreakpoint breakpoint : breakpoints) {
    if (this.breakpoints.contains(breakpoint)) {
      try {
        breakpoint.close();
        this.breakpoints.remove(breakpoint);
        breakpointMap.remove(String.valueOf(breakpoint.lineNumber()));
      }
 catch (      Exception e) {
        logger.severe(String.format("String_Node_Str",e));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Removes the specified breakpoints from breakpoint manager.
 */
private void removeBreakpointsInternally(String source,IBreakpoint[] breakpoints){
  Map<String,IBreakpoint> breakpointMap=this.sourceToBreakpoints.get(source);
  if (breakpointMap == null || breakpointMap.isEmpty() || breakpoints.length == 0) {
    return;
  }
  for (  IBreakpoint breakpoint : breakpoints) {
    if (this.breakpoints.contains(breakpoint)) {
      try {
        breakpoint.close();
        this.breakpoints.remove(breakpoint);
        breakpointMap.remove(String.valueOf(breakpoint.lineNumber()));
      }
 catch (      Exception e) {
        logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
      }
    }
  }
}
Program: 37396
Project: 37396
Buggy source:
@Override public Messages.Response dispatchRequest(Messages.Request request){
  Messages.Response response=new Messages.Response();
  response.request_seq=request.seq;
  response.command=request.command;
  response.success=true;
  Command command=Command.parse(request.command);
  Arguments cmdArgs=JsonUtils.fromJson(request.arguments,command.getArgumentType());
  try {
    List<IDebugRequestHandler> handlers=requestHandlers.get(command);
    if (handlers != null && !handlers.isEmpty()) {
      for (      IDebugRequestHandler handler : handlers) {
        handler.handle(command,cmdArgs,response,this.debugContext);
      }
    }
 else {
      AdapterUtils.setErrorResponse(response,ErrorCode.UNRECOGNIZED_REQUEST_FAILURE,String.format("String_Node_Str",request.command));
    }
  }
 catch (  Exception e) {
    logger.severe(String.format("String_Node_Str",e.toString()));
    AdapterUtils.setErrorResponse(response,ErrorCode.UNKNOWN_FAILURE,e.getMessage() != null ? e.getMessage() : e.toString());
  }
  return response;
}

Fixed version (ground truth):
@Override public Messages.Response dispatchRequest(Messages.Request request){
  Messages.Response response=new Messages.Response();
  response.request_seq=request.seq;
  response.command=request.command;
  response.success=true;
  Command command=Command.parse(request.command);
  Arguments cmdArgs=JsonUtils.fromJson(request.arguments,command.getArgumentType());
  try {
    List<IDebugRequestHandler> handlers=requestHandlers.get(command);
    if (handlers != null && !handlers.isEmpty()) {
      for (      IDebugRequestHandler handler : handlers) {
        handler.handle(command,cmdArgs,response,this.debugContext);
      }
    }
 else {
      AdapterUtils.setErrorResponse(response,ErrorCode.UNRECOGNIZED_REQUEST_FAILURE,String.format("String_Node_Str",request.command));
    }
  }
 catch (  Exception e) {
    logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
    AdapterUtils.setErrorResponse(response,ErrorCode.UNKNOWN_FAILURE,e.getMessage() != null ? e.getMessage() : e.toString());
  }
  return response;
}
Program: 37397
Project: 37397
Buggy source:
/** 
 * A while-loop to parse input data and send output data constantly.
 */
public void start(){
  char[] buffer=new char[BUFFER_SIZE];
  try {
    while (!this.terminateSession) {
      int read=this.reader.read(buffer,0,BUFFER_SIZE);
      if (read == -1) {
        break;
      }
      this.rawData.append(new String(buffer,0,read).getBytes(PROTOCOL_ENCODING));
      this.processData();
    }
  }
 catch (  IOException e) {
    logger.severe(String.format("String_Node_Str",e));
  }
}

Fixed version (ground truth):
/** 
 * A while-loop to parse input data and send output data constantly.
 */
public void start(){
  char[] buffer=new char[BUFFER_SIZE];
  try {
    while (!this.terminateSession) {
      int read=this.reader.read(buffer,0,BUFFER_SIZE);
      if (read == -1) {
        break;
      }
      this.rawData.append(new String(buffer,0,read).getBytes(PROTOCOL_ENCODING));
      this.processData();
    }
  }
 catch (  IOException e) {
    logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
  }
}
Program: 37398
Project: 37398
Buggy source:
private void sendMessage(Messages.ProtocolMessage message){
  message.seq=this.sequenceNumber.getAndIncrement();
  String jsonMessage=JsonUtils.toJson(message);
  byte[] jsonBytes=jsonMessage.getBytes(PROTOCOL_ENCODING);
  String header=String.format("String_Node_Str",jsonBytes.length,TWO_CRLF);
  byte[] headerBytes=header.getBytes(PROTOCOL_ENCODING);
  byte[] data=new byte[headerBytes.length + jsonBytes.length];
  System.arraycopy(headerBytes,0,data,0,headerBytes.length);
  System.arraycopy(jsonBytes,0,data,headerBytes.length,jsonBytes.length);
  String utf8Data=new String(data,PROTOCOL_ENCODING);
  try {
    logger.info("String_Node_Str" + new String(data));
    this.writer.write(utf8Data);
    this.writer.flush();
  }
 catch (  IOException e) {
    logger.severe(String.format("String_Node_Str",e));
  }
}

Fixed version (ground truth):
private void sendMessage(Messages.ProtocolMessage message){
  message.seq=this.sequenceNumber.getAndIncrement();
  String jsonMessage=JsonUtils.toJson(message);
  byte[] jsonBytes=jsonMessage.getBytes(PROTOCOL_ENCODING);
  String header=String.format("String_Node_Str",jsonBytes.length,TWO_CRLF);
  byte[] headerBytes=header.getBytes(PROTOCOL_ENCODING);
  byte[] data=new byte[headerBytes.length + jsonBytes.length];
  System.arraycopy(headerBytes,0,data,0,headerBytes.length);
  System.arraycopy(jsonBytes,0,data,headerBytes.length,jsonBytes.length);
  String utf8Data=new String(data,PROTOCOL_ENCODING);
  try {
    logger.info("String_Node_Str" + new String(data));
    this.writer.write(utf8Data);
    this.writer.flush();
  }
 catch (  IOException e) {
    logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
  }
}
Program: 37399
Project: 37399
Buggy source:
private void dispatchRequest(String request){
  try {
    logger.info("String_Node_Str" + request);
    Messages.Request message=JsonUtils.fromJson(request,Messages.Request.class);
    if (message.type.equals("String_Node_Str")) {
synchronized (this) {
        this.isDispatchingData=true;
      }
      try {
        Messages.Response response=this.debugAdapter.dispatchRequest(message);
        if (message.command.equals("String_Node_Str")) {
          this.stop();
        }
        sendMessage(response);
      }
 catch (      Exception e) {
        logger.severe(String.format("String_Node_Str",e));
      }
    }
  }
  finally {
synchronized (this) {
      this.isDispatchingData=false;
    }
    while (this.eventQueue.peek() != null) {
      sendMessage(this.eventQueue.poll());
    }
  }
}

Fixed version (ground truth):
private void dispatchRequest(String request){
  try {
    logger.info("String_Node_Str" + request);
    Messages.Request message=JsonUtils.fromJson(request,Messages.Request.class);
    if (message.type.equals("String_Node_Str")) {
synchronized (this) {
        this.isDispatchingData=true;
      }
      try {
        Messages.Response response=this.debugAdapter.dispatchRequest(message);
        if (message.command.equals("String_Node_Str")) {
          this.stop();
        }
        sendMessage(response);
      }
 catch (      Exception e) {
        logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
      }
    }
  }
  finally {
synchronized (this) {
      this.isDispatchingData=false;
    }
    while (this.eventQueue.peek() != null) {
      sendMessage(this.eventQueue.poll());
    }
  }
}
Program: 37400
Project: 37400
Buggy source:
/** 
 * Gets the server port.
 */
public synchronized int getPort(){
  if (this.serverSocket != null) {
    return this.serverSocket.getLocalPort();
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Gets the server port.
 */
@Override public synchronized int getPort(){
  if (this.serverSocket != null) {
    return this.serverSocket.getLocalPort();
  }
  return -1;
}
Program: 37401
Project: 37401
Buggy source:
private synchronized void closeServerSocket(){
  if (serverSocket != null) {
    try {
      logger.info("String_Node_Str" + serverSocket.getLocalPort());
      serverSocket.close();
    }
 catch (    IOException e) {
      logger.severe(String.format("String_Node_Str",e));
    }
  }
  serverSocket=null;
}

Fixed version (ground truth):
private synchronized void closeServerSocket(){
  if (serverSocket != null) {
    try {
      logger.info("String_Node_Str" + serverSocket.getLocalPort());
      serverSocket.close();
    }
 catch (    IOException e) {
      logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
    }
  }
  serverSocket=null;
}
Program: 37402
Project: 37402
Buggy source:
public synchronized void stop(){
  closeServerSocket();
  shutdownConnectionPool(true);
}

Fixed version (ground truth):
@Override public synchronized void stop(){
  closeServerSocket();
  shutdownConnectionPool(true);
}
Program: 37403
Project: 37403
Buggy source:
/** 
 * Starts the server if it's not started yet.
 */
public synchronized void start(){
  if (this.serverSocket != null && !this.isStarted) {
    this.isStarted=true;
    this.executor=new ThreadPoolExecutor(0,100,30L,TimeUnit.SECONDS,new SynchronousQueue<Runnable>());
    new Thread(new Runnable(){
      @Override public void run(){
        while (true) {
          try {
            Socket connection=serverSocket.accept();
            executor.submit(createConnectionTask(connection));
          }
 catch (          IOException e1) {
            logger.severe(String.format("String_Node_Str",e1));
            closeServerSocket();
            shutdownConnectionPool(false);
            return;
          }
        }
      }
    }
,"String_Node_Str").start();
  }
}

Fixed version (ground truth):
/** 
 * Starts the server if it's not started yet.
 */
@Override public synchronized void start(){
  if (this.serverSocket != null && !this.isStarted) {
    this.isStarted=true;
    this.executor=new ThreadPoolExecutor(0,100,30L,TimeUnit.SECONDS,new SynchronousQueue<Runnable>());
    new Thread(new Runnable(){
      @Override public void run(){
        while (true) {
          try {
            Socket connection=serverSocket.accept();
            executor.submit(createConnectionTask(connection));
          }
 catch (          IOException e) {
            logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
            closeServerSocket();
            shutdownConnectionPool(false);
            return;
          }
        }
      }
    }
,"String_Node_Str").start();
  }
}
Program: 37404
Project: 37404
Buggy source:
private Runnable createConnectionTask(Socket connection){
  return new Runnable(){
    public void run(){
      try {
        ProtocolServer protocolServer=new ProtocolServer(connection.getInputStream(),connection.getOutputStream(),JdtProviderContextFactory.createProviderContext());
        protocolServer.start();
      }
 catch (      IOException e) {
        logger.severe(String.format("String_Node_Str",e));
      }
 finally {
        logger.info("String_Node_Str");
      }
    }
  }
;
}

Fixed version (ground truth):
private Runnable createConnectionTask(Socket connection){
  return new Runnable(){
    @Override public void run(){
      try {
        ProtocolServer protocolServer=new ProtocolServer(connection.getInputStream(),connection.getOutputStream(),JdtProviderContextFactory.createProviderContext());
        protocolServer.start();
      }
 catch (      IOException e) {
        logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
      }
 finally {
        logger.info("String_Node_Str");
      }
    }
  }
;
}
Program: 37405
Project: 37405
Buggy source:
public void run(){
  try {
    ProtocolServer protocolServer=new ProtocolServer(connection.getInputStream(),connection.getOutputStream(),JdtProviderContextFactory.createProviderContext());
    protocolServer.start();
  }
 catch (  IOException e) {
    logger.severe(String.format("String_Node_Str",e));
  }
 finally {
    logger.info("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    ProtocolServer protocolServer=new ProtocolServer(connection.getInputStream(),connection.getOutputStream(),JdtProviderContextFactory.createProviderContext());
    protocolServer.start();
  }
 catch (  IOException e) {
    logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
  }
 finally {
    logger.info("String_Node_Str");
  }
}
Program: 37406
Project: 37406
Buggy source:
private JavaDebugServer(){
  try {
    this.serverSocket=new ServerSocket(0,1);
  }
 catch (  IOException e) {
    logger.severe(String.format("String_Node_Str",e));
  }
}

Fixed version (ground truth):
private JavaDebugServer(){
  try {
    this.serverSocket=new ServerSocket(0,1);
  }
 catch (  IOException e) {
    logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
  }
}
Program: 37407
Project: 37407
Buggy source:
private String searchDeclarationFileByFqn(String fullyQualifiedName){
  String projectName=(String)context.get(Constants.PROJECTNAME);
  try {
    IJavaSearchScope searchScope=projectName != null ? createSearchScope(getJavaProjectFromName(projectName)) : SearchEngine.createWorkspaceScope();
    SearchPattern pattern=SearchPattern.createPattern(fullyQualifiedName,IJavaSearchConstants.TYPE,IJavaSearchConstants.DECLARATIONS,SearchPattern.R_EXACT_MATCH);
    ArrayList<String> uris=new ArrayList<String>();
    SearchRequestor requestor=new SearchRequestor(){
      @Override public void acceptSearchMatch(      SearchMatch match){
        Object element=match.getElement();
        if (element instanceof IType) {
          IType type=(IType)element;
          if (type.isBinary()) {
            try {
              if (type.getSource() != null) {
                uris.add(getFileURI(type.getClassFile()));
              }
            }
 catch (            JavaModelException e) {
            }
          }
 else {
            uris.add(getFileURI(type.getResource()));
          }
        }
      }
    }
;
    SearchEngine searchEngine=new SearchEngine();
    searchEngine.search(pattern,new SearchParticipant[]{SearchEngine.getDefaultSearchParticipant()},searchScope,requestor,null);
    return uris.size() == 0 ? null : uris.get(0);
  }
 catch (  CoreException e) {
    logger.severe(String.format("String_Node_Str",e));
  }
  return null;
}

Fixed version (ground truth):
private String searchDeclarationFileByFqn(String fullyQualifiedName){
  String projectName=(String)context.get(Constants.PROJECTNAME);
  try {
    IJavaSearchScope searchScope=projectName != null ? createSearchScope(getJavaProjectFromName(projectName)) : SearchEngine.createWorkspaceScope();
    SearchPattern pattern=SearchPattern.createPattern(fullyQualifiedName,IJavaSearchConstants.TYPE,IJavaSearchConstants.DECLARATIONS,SearchPattern.R_EXACT_MATCH);
    ArrayList<String> uris=new ArrayList<String>();
    SearchRequestor requestor=new SearchRequestor(){
      @Override public void acceptSearchMatch(      SearchMatch match){
        Object element=match.getElement();
        if (element instanceof IType) {
          IType type=(IType)element;
          if (type.isBinary()) {
            try {
              if (type.getSource() != null) {
                uris.add(getFileURI(type.getClassFile()));
              }
            }
 catch (            JavaModelException e) {
            }
          }
 else {
            uris.add(getFileURI(type.getResource()));
          }
        }
      }
    }
;
    SearchEngine searchEngine=new SearchEngine();
    searchEngine.search(pattern,new SearchParticipant[]{SearchEngine.getDefaultSearchParticipant()},searchScope,requestor,null);
    return uris.size() == 0 ? null : uris.get(0);
  }
 catch (  CoreException e) {
    logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
  }
  return null;
}
Program: 37408
Project: 37408
Buggy source:
public boolean supportsRealtimeBreakpointVerification(){
  return true;
}

Fixed version (ground truth):
@Override public boolean supportsRealtimeBreakpointVerification(){
  return true;
}
Program: 37409
Project: 37409
Buggy source:
private String getContents(IClassFile cf){
  String source=null;
  if (cf != null) {
    try {
      IBuffer buffer=cf.getBuffer();
      if (buffer != null) {
        source=buffer.getContents();
      }
      if (source == null) {
        source=disassemble(cf);
      }
    }
 catch (    JavaModelException e) {
      logger.severe(String.format("String_Node_Str",e));
    }
    if (source == null) {
      source="String_Node_Str";
    }
  }
  return source;
}

Fixed version (ground truth):
private String getContents(IClassFile cf){
  String source=null;
  if (cf != null) {
    try {
      IBuffer buffer=cf.getBuffer();
      if (buffer != null) {
        source=buffer.getContents();
      }
      if (source == null) {
        source=disassemble(cf);
      }
    }
 catch (    JavaModelException e) {
      logger.log(Level.SEVERE,String.format("String_Node_Str",e.toString()),e);
    }
    if (source == null) {
      source="String_Node_Str";
    }
  }
  return source;
}
Program: 37411
Project: 37411
Buggy source:
private List<BreakpointRequest> createBreakpointRequests(List<ReferenceType> refTypes,int lineNumber,int hitCount){
  List<Location> locations=collectLocations(refTypes,lineNumber);
  List<Location> existingLocations=new ArrayList<>(requests.size());
  Observable.fromIterable(requests).filter(request -> request instanceof BreakpointRequest).map(request -> ((BreakpointRequest)request).location()).toList().subscribe(list -> {
    existingLocations.addAll(list);
  }
);
  List<Location> newLocations=new ArrayList<>(locations.size());
  Observable.fromIterable(locations).filter(location -> !existingLocations.contains(location)).toList().subscribe(list -> {
    newLocations.addAll(list);
  }
);
  List<BreakpointRequest> newRequests=new ArrayList<>(newLocations.size());
  newLocations.forEach(location -> {
    try {
      BreakpointRequest request=vm.eventRequestManager().createBreakpointRequest(location);
      request.setSuspendPolicy(BreakpointRequest.SUSPEND_EVENT_THREAD);
      if (hitCount > 0) {
        request.addCountFilter(hitCount);
      }
      request.enable();
      newRequests.add(request);
    }
 catch (    VMDisconnectedException ex) {
    }
  }
);
  return newRequests;
}

Fixed version (ground truth):
private List<BreakpointRequest> createBreakpointRequests(List<ReferenceType> refTypes,int lineNumber,int hitCount,boolean includeNestedTypes){
  List<Location> locations=collectLocations(refTypes,lineNumber,includeNestedTypes);
  List<Location> existingLocations=new ArrayList<>(requests.size());
  Observable.fromIterable(requests).filter(request -> request instanceof BreakpointRequest).map(request -> ((BreakpointRequest)request).location()).toList().subscribe(list -> {
    existingLocations.addAll(list);
  }
);
  List<Location> newLocations=new ArrayList<>(locations.size());
  Observable.fromIterable(locations).filter(location -> !existingLocations.contains(location)).toList().subscribe(list -> {
    newLocations.addAll(list);
  }
);
  List<BreakpointRequest> newRequests=new ArrayList<>(newLocations.size());
  newLocations.forEach(location -> {
    try {
      BreakpointRequest request=vm.eventRequestManager().createBreakpointRequest(location);
      request.setSuspendPolicy(BreakpointRequest.SUSPEND_EVENT_THREAD);
      if (hitCount > 0) {
        request.addCountFilter(hitCount);
      }
      request.enable();
      newRequests.add(request);
    }
 catch (    VMDisconnectedException ex) {
    }
  }
);
  return newRequests;
}
Program: 37413
Project: 37413
Buggy source:
private static List<Location> collectLocations(List<ReferenceType> refTypes,int lineNumber){
  List<Location> locations=new ArrayList<>();
  try {
    refTypes.forEach(refType -> {
      locations.addAll(collectLocations(refType,lineNumber));
      locations.addAll(collectLocations(refType.nestedTypes(),lineNumber));
    }
);
  }
 catch (  VMDisconnectedException ex) {
  }
  return locations;
}

Fixed version (ground truth):
private static List<Location> collectLocations(List<ReferenceType> refTypes,int lineNumber,boolean includeNestedTypes){
  List<Location> locations=new ArrayList<>();
  try {
    refTypes.forEach(refType -> {
      List<Location> newLocations=collectLocations(refType,lineNumber);
      if (!newLocations.isEmpty()) {
        locations.addAll(newLocations);
      }
 else       if (includeNestedTypes) {
        for (        ReferenceType nestedType : refType.nestedTypes()) {
          List<Location> nestedLocations=collectLocations(nestedType,lineNumber);
          if (!nestedLocations.isEmpty()) {
            locations.addAll(nestedLocations);
            break;
          }
        }
      }
    }
);
  }
 catch (  VMDisconnectedException ex) {
  }
  return locations;
}
Program: 37415
Project: 37415
Buggy source:
public static String getSessionGuid(){
  return threadLocal.get().sessionGuid;
}

Fixed version (ground truth):
public static String getSessionGuid(){
  return threadLocal.get() == null ? "String_Node_Str" : threadLocal.get().sessionGuid;
}
Program: 37417
Project: 37417
Buggy source:
/** 
 * Get the local variables of an stack frame.
 * @param stackFrame the stack frame
 * @return local variable list
 * @throws AbsentInformationException when there is any error in retrieving information
 */
public static List<Variable> listLocalVariables(StackFrame stackFrame) throws AbsentInformationException {
  List<Variable> res=new ArrayList<>();
  try {
    for (    LocalVariable localVariable : stackFrame.visibleVariables()) {
      Variable var=new Variable(localVariable.name(),stackFrame.getValue(localVariable));
      var.local=localVariable;
      res.add(var);
    }
  }
 catch (  AbsentInformationException ex) {
    if (stackFrame.location().method().isNative()) {
      return res;
    }
    int argId=0;
    try {
      List<Value> arguments=stackFrame.getArgumentValues();
      if (arguments == null) {
        return res;
      }
      for (      Value argValue : arguments) {
        Variable var=new Variable("String_Node_Str" + argId,argValue);
        var.argumentIndex=argId++;
        res.add(var);
      }
    }
 catch (    InternalException ex2) {
      if (ex2.errorCode() != 32) {
        throw ex;
      }
    }
  }
  return res;
}

Fixed version (ground truth):
/** 
 * Get the local variables of an stack frame.
 * @param stackFrame the stack frame
 * @return local variable list
 * @throws AbsentInformationException when there is any error in retrieving information
 */
public static List<Variable> listLocalVariables(StackFrame stackFrame) throws AbsentInformationException {
  List<Variable> res=new ArrayList<>();
  if (stackFrame.location().method().isNative()) {
    return res;
  }
  try {
    for (    LocalVariable localVariable : stackFrame.visibleVariables()) {
      Variable var=new Variable(localVariable.name(),stackFrame.getValue(localVariable));
      var.local=localVariable;
      res.add(var);
    }
  }
 catch (  AbsentInformationException ex) {
    try {
      if (stackFrame.location().method().argumentTypes().size() == 0) {
        return res;
      }
    }
 catch (    ClassNotLoadedException ex2) {
    }
    int argId=0;
    try {
      List<Value> arguments=stackFrame.getArgumentValues();
      if (arguments == null) {
        return res;
      }
      for (      Value argValue : arguments) {
        Variable var=new Variable("String_Node_Str" + argId,argValue);
        var.argumentIndex=argId++;
        res.add(var);
      }
    }
 catch (    InternalException ex2) {
      if (ex2.errorCode() != 32) {
        throw ex;
      }
    }
  }
  return res;
}
Program: 37419
Project: 37419
Buggy source:
@Override public Object executeCommand(String commandId,List<Object> arguments){
  if (DEBUG_STARTSESSION.equals(commandId)) {
  }
 else   if (RESOLVE_CLASSPATH.equals(commandId)) {
    ResolveClasspathsHandler handler=new ResolveClasspathsHandler();
    return handler.resolveClasspaths(arguments);
  }
 else   if (BUILD_WORKSPACE.equals(commandId)) {
  }
  return null;
}

Fixed version (ground truth):
@Override public Object executeCommand(String commandId,List<Object> arguments){
  if (DEBUG_STARTSESSION.equals(commandId)) {
    IDebugServer debugServer=JavaDebugServer.getInstance();
    debugServer.start();
    return debugServer.getPort();
  }
 else   if (RESOLVE_CLASSPATH.equals(commandId)) {
    ResolveClasspathsHandler handler=new ResolveClasspathsHandler();
    return handler.resolveClasspaths(arguments);
  }
 else   if (BUILD_WORKSPACE.equals(commandId)) {
  }
  return null;
}
Program: 37420
Project: 37420
Buggy source:
private String searchDeclarationFileByFqn(String fullyQualifiedName){
  return null;
}

Fixed version (ground truth):
private String searchDeclarationFileByFqn(String fullyQualifiedName){
  String projectName=(String)context.get(Constants.PROJECTNAME);
  try {
    IJavaSearchScope searchScope=projectName != null ? JDTUtils.createSearchScope(getJavaProjectFromName(projectName)) : SearchEngine.createWorkspaceScope();
    SearchPattern pattern=SearchPattern.createPattern(fullyQualifiedName,IJavaSearchConstants.TYPE,IJavaSearchConstants.DECLARATIONS,SearchPattern.R_EXACT_MATCH);
    ArrayList<String> uris=new ArrayList<String>();
    SearchRequestor requestor=new SearchRequestor(){
      @Override public void acceptSearchMatch(      SearchMatch match){
        Object element=match.getElement();
        if (element instanceof IType) {
          IType type=(IType)element;
          uris.add(type.isBinary() ? getFileURI(type.getClassFile()) : JDTUtils.getFileURI(type.getResource()));
        }
      }
    }
;
    SearchEngine searchEngine=new SearchEngine();
    searchEngine.search(pattern,new SearchParticipant[]{SearchEngine.getDefaultSearchParticipant()},searchScope,requestor,null);
    return uris.size() == 0 ? null : uris.get(0);
  }
 catch (  CoreException e) {
    Logger.logException("String_Node_Str",e);
  }
  return null;
}
Program: 37421
Project: 37421
Buggy source:
private String getContents(IClassFile cf){
  String source=null;
  if (cf != null) {
    try {
      IBuffer buffer=cf.getBuffer();
      if (buffer != null) {
        source=buffer.getContents();
      }
      if (source == null) {
      }
    }
 catch (    JavaModelException e) {
      Logger.logException("String_Node_Str",e);
    }
    if (source == null) {
      source="String_Node_Str";
    }
  }
  return source;
}

Fixed version (ground truth):
private String getContents(IClassFile cf){
  String source=null;
  if (cf != null) {
    try {
      IBuffer buffer=cf.getBuffer();
      if (buffer != null) {
        source=buffer.getContents();
      }
      if (source == null) {
        source=JDTUtils.disassemble(cf);
      }
    }
 catch (    JavaModelException e) {
      Logger.logException("String_Node_Str",e);
    }
    if (source == null) {
      source="String_Node_Str";
    }
  }
  return source;
}
Program: 37422
Project: 37422
Buggy source:
@Override public String getSourceContents(String uri){
  if (uri == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
@Override public String getSourceContents(String uri){
  if (uri == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  IClassFile cf=JDTUtils.resolveClassFile(uri);
  return getContents(cf);
}
Program: 37423
Project: 37423
Buggy source:
/** 
 * For a given source file and a list of line locations, return the fully qualified names of the type of the line location. If the line location points an empty line or invalid line, it returns a null fully qualified name.
 */
@Override public String[] getFullyQualifiedName(String uri,int[] lines,int[] columns) throws DebugException {
  if (uri == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (lines == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (columns == null) {
    columns=new int[lines.length];
  }
 else   if (lines.length != columns.length) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String[] fqns=new String[lines.length];
  return fqns;
}

Fixed version (ground truth):
/** 
 * For a given source file and a list of line locations, return the fully qualified names of the type of the line location. If the line location points an empty line or invalid line, it returns a null fully qualified name.
 */
@Override public String[] getFullyQualifiedName(String uri,int[] lines,int[] columns) throws DebugException {
  if (uri == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (lines == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (columns == null) {
    columns=new int[lines.length];
  }
 else   if (lines.length != columns.length) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String[] fqns=new String[lines.length];
  ITypeRoot typeRoot=JDTUtils.resolveCompilationUnit(uri);
  if (typeRoot == null) {
    typeRoot=JDTUtils.resolveClassFile(uri);
  }
  if (typeRoot != null && lines.length > 0) {
    final ASTParser parser=ASTParser.newParser(AST.JLS8);
    parser.setResolveBindings(true);
    parser.setBindingsRecovery(true);
    parser.setStatementsRecovery(true);
    parser.setSource(typeRoot);
    CompilationUnit cunit=(CompilationUnit)parser.createAST(null);
    for (int i=0; i < lines.length; i++) {
      ValidBreakpointLocationLocator locator=new ValidBreakpointLocationLocator(cunit,lines[i],true,true);
      cunit.accept(locator);
      if (lines[i] == locator.getLineLocation()) {
        fqns[i]=locator.getFullyQualifiedTypeName();
      }
    }
  }
  return fqns;
}
Program: 37424
Project: 37424
Buggy source:
private IBreakpoint[] convertClientBreakpointsToDebugger(String sourceFile,Types.SourceBreakpoint[] sourceBreakpoints,IDebugAdapterContext context) throws DebugException {
  int[] lines=Arrays.asList(sourceBreakpoints).stream().map(sourceBreakpoint -> {
    return AdapterUtils.convertLineNumber(sourceBreakpoint.line,context.isClientLinesStartAt1(),context.isDebuggerLinesStartAt1());
  }
).mapToInt(line -> line).toArray();
  ISourceLookUpProvider sourceProvider=context.getProvider(ISourceLookUpProvider.class);
  String[] fqns=sourceProvider.getFullyQualifiedName(sourceFile,lines,null);
  IBreakpoint[] breakpoints=new IBreakpoint[lines.length];
  for (int i=0; i < lines.length; i++) {
    int hitCount=0;
    try {
      hitCount=Integer.parseInt(sourceBreakpoints[i].hitCondition);
    }
 catch (    NumberFormatException e) {
      hitCount=0;
    }
    breakpoints[i]=context.getDebugSession().createBreakpoint(fqns[i],lines[i],hitCount);
  }
  return breakpoints;
}

Fixed version (ground truth):
private IBreakpoint[] convertClientBreakpointsToDebugger(String sourceFile,Types.SourceBreakpoint[] sourceBreakpoints,IDebugAdapterContext context) throws DebugException {
  int[] lines=Arrays.asList(sourceBreakpoints).stream().map(sourceBreakpoint -> {
    return AdapterUtils.convertLineNumber(sourceBreakpoint.line,context.isClientLinesStartAt1(),context.isDebuggerLinesStartAt1());
  }
).mapToInt(line -> line).toArray();
  ISourceLookUpProvider sourceProvider=context.getProvider(ISourceLookUpProvider.class);
  String[] fqns=sourceProvider.getFullyQualifiedName(sourceFile,lines,null);
  IBreakpoint[] breakpoints=new IBreakpoint[lines.length];
  for (int i=0; i < lines.length; i++) {
    int hitCount=0;
    try {
      hitCount=Integer.parseInt(sourceBreakpoints[i].hitCondition);
    }
 catch (    NumberFormatException e) {
      hitCount=0;
    }
    breakpoints[i]=context.getDebugSession().createBreakpoint(fqns[i],lines[i],hitCount);
    if (sourceProvider.supportsRealtimeBreakpointVerification() && StringUtils.isNotBlank(fqns[i])) {
      breakpoints[i].putProperty("String_Node_Str",true);
    }
  }
  return breakpoints;
}
Program: 37425
Project: 37425
Buggy source:
@Override public String[] getFullyQualifiedName(String uri,int[] lines,int[] columns) throws DebugException {
  if (uri == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (lines == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (columns == null) {
    columns=new int[lines.length];
  }
 else   if (lines.length != columns.length) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String[] fqns=new String[lines.length];
  ITypeRoot typeRoot=JDTUtils.resolveCompilationUnit(uri);
  if (typeRoot == null) {
    typeRoot=JDTUtils.resolveClassFile(uri);
  }
  for (int i=0; i < lines.length; i++) {
    String fqn=null;
    if (typeRoot != null) {
      try {
        int offset=JsonRpcHelpers.toOffset(typeRoot.getBuffer(),lines[i],columns[i]);
        IJavaElement javaElement=typeRoot.getElementAt(offset);
        if (javaElement instanceof SourceField || javaElement instanceof SourceMethod || javaElement instanceof BinaryMember) {
          IType type=((IMember)javaElement).getDeclaringType();
          fqn=type.getFullyQualifiedName();
        }
 else         if (javaElement instanceof SourceType) {
          fqn=((SourceType)javaElement).getFullyQualifiedName();
        }
      }
 catch (      JavaModelException e) {
        Logger.logException("String_Node_Str" + lines[i],e);
        throw new DebugException(String.format("String_Node_Str",lines[i],e.getMessage()),e);
      }
    }
    fqns[i]=fqn;
  }
  return fqns;
}

Fixed version (ground truth):
/** 
 * For a given source file and a list of line locations, return the fully qualified names of the type of the line location. If the line location points an empty line or invalid line, it returns a null fully qualified name.
 */
@Override public String[] getFullyQualifiedName(String uri,int[] lines,int[] columns) throws DebugException {
  if (uri == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (lines == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (columns == null) {
    columns=new int[lines.length];
  }
 else   if (lines.length != columns.length) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String[] fqns=new String[lines.length];
  ITypeRoot typeRoot=JDTUtils.resolveCompilationUnit(uri);
  if (typeRoot == null) {
    typeRoot=JDTUtils.resolveClassFile(uri);
  }
  if (typeRoot != null && lines.length > 0) {
    final ASTParser parser=ASTParser.newParser(AST.JLS8);
    parser.setResolveBindings(true);
    parser.setBindingsRecovery(true);
    parser.setStatementsRecovery(true);
    parser.setSource(typeRoot);
    CompilationUnit cunit=(CompilationUnit)parser.createAST(null);
    for (int i=0; i < lines.length; i++) {
      ValidBreakpointLocationLocator locator=new ValidBreakpointLocationLocator(cunit,lines[i],true,true);
      cunit.accept(locator);
      if (lines[i] == locator.getLineLocation()) {
        fqns[i]=locator.getFullyQualifiedTypeName();
      }
    }
  }
  return fqns;
}
Program: 37426
Project: 37426
Buggy source:
@Override public boolean equals(Object obj){
  if (!(obj instanceof IBreakpoint)) {
    return super.equals(obj);
  }
  IBreakpoint breakpoint=(IBreakpoint)obj;
  return this.className().equals(breakpoint.className()) && this.lineNumber() == breakpoint.lineNumber();
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (!(obj instanceof IBreakpoint)) {
    return super.equals(obj);
  }
  IBreakpoint breakpoint=(IBreakpoint)obj;
  return Objects.equals(this.className(),breakpoint.className()) && this.lineNumber() == breakpoint.lineNumber();
}
Program: 37427
Project: 37427
Buggy source:
private void resume(Requests.ContinueArguments arguments,Response response,IDebugAdapterContext context){
  boolean allThreadsContinued=true;
  ThreadReference thread=DebugUtility.getThread(context.getDebugSession(),arguments.threadId);
  if (thread != null) {
    allThreadsContinued=false;
    thread.resume();
    checkThreadRunningAndRecycleIds(thread,context);
  }
 else {
    context.getDebugSession().resume();
    context.getRecyclableIdPool().removeAllObjects();
  }
  response.body=new Responses.ContinueResponseBody(allThreadsContinued);
}

Fixed version (ground truth):
private void resume(Requests.ContinueArguments arguments,Response response,IDebugAdapterContext context){
  boolean allThreadsContinued=true;
  ThreadReference thread=DebugUtility.getThread(context.getDebugSession(),arguments.threadId);
  if (thread != null) {
    allThreadsContinued=false;
    DebugUtility.resumeThread(thread);
    checkThreadRunningAndRecycleIds(thread,context);
  }
 else {
    context.getDebugSession().resume();
    context.getRecyclableIdPool().removeAllObjects();
  }
  response.body=new Responses.ContinueResponseBody(allThreadsContinued);
}
Program: 37428
Project: 37428
Buggy source:
@Override public void resume(){
  vm.resume();
}

Fixed version (ground truth):
@Override public void resume(){
  vm.resume();
  for (  ThreadReference tr : DebugUtility.getAllThreadsSafely(this)) {
    DebugUtility.resumeThread(tr);
  }
}
Program: 37432
Project: 37432
Buggy source:
@Override public String getSourceFileURI(String fullyQualifiedName,String sourcePath){
  if (fullyQualifiedName == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String projectName=(String)context.get(Constants.PROJECTNAME);
  try {
    IJavaSearchScope searchScope=projectName != null ? JDTUtils.createSearchScope(getJavaProjectFromName(projectName)) : SearchEngine.createWorkspaceScope();
    SearchPattern pattern=SearchPattern.createPattern(fullyQualifiedName,IJavaSearchConstants.TYPE,IJavaSearchConstants.DECLARATIONS,SearchPattern.R_EXACT_MATCH);
    ArrayList<String> uris=new ArrayList<String>();
    SearchRequestor requestor=new SearchRequestor(){
      @Override public void acceptSearchMatch(      SearchMatch match){
        Object element=match.getElement();
        if (element instanceof IType) {
          IType type=(IType)element;
          uris.add(type.isBinary() ? JDTUtils.getFileURI(type.getClassFile()) : JDTUtils.getFileURI(type.getResource()));
        }
      }
    }
;
    SearchEngine searchEngine=new SearchEngine();
    searchEngine.search(pattern,new SearchParticipant[]{SearchEngine.getDefaultSearchParticipant()},searchScope,requestor,null);
    return uris.size() == 0 ? null : uris.get(0);
  }
 catch (  CoreException e) {
    Logger.logException("String_Node_Str",e);
  }
  return null;
}

Fixed version (ground truth):
@Override public String getSourceFileURI(String fullyQualifiedName,String sourcePath){
  if (fullyQualifiedName == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (fullyQualifiedName.indexOf("String_Node_Str") >= 0) {
    return searchDeclarationFileByFqn(AdapterUtils.parseEnclosingType(fullyQualifiedName));
  }
 else {
    return searchDeclarationFileByFqn(fullyQualifiedName);
  }
}
Program: 37433
Project: 37433
Buggy source:
@Override public void setExceptionBreakpoints(boolean notifyCaught,boolean notifyUncaught){
  EventRequestManager manager=vm.eventRequestManager();
  ArrayList<ExceptionRequest> legacy=new ArrayList<ExceptionRequest>(manager.exceptionRequests());
  manager.deleteEventRequests(legacy);
  ExceptionRequest request=manager.createExceptionRequest(null,notifyCaught,notifyUncaught);
  request.enable();
}

Fixed version (ground truth):
@Override public void setExceptionBreakpoints(boolean notifyCaught,boolean notifyUncaught){
  EventRequestManager manager=vm.eventRequestManager();
  ArrayList<ExceptionRequest> legacy=new ArrayList<ExceptionRequest>(manager.exceptionRequests());
  manager.deleteEventRequests(legacy);
  ExceptionRequest request=manager.createExceptionRequest(null,notifyCaught,notifyUncaught);
  request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
  request.enable();
}