nus-yam/ex-repair huggingface dataset:
Program: 3153
Project: 3153
Buggy source:
public void clearPlayer() throws ConnectorException {
synchronized (playingFieldsMutex) {
    playerCleared=true;
    playerThread.interrupt();
    playerThread=null;
    Connector.getInstance().removeConnectorListener(playingLister);
    playingLister=null;
    player=null;
    Connector.setInstance(null);
  }
}

Fixed version (ground truth):
public void clearPlayer() throws ConnectorException {
synchronized (playingFieldsMutex) {
    playerThread.interrupt();
    playerThread=null;
    Connector.getInstance().removeConnectorListener(playingLister);
    playingLister=null;
    player=null;
    Connector.setInstance(null);
  }
}
Program: 3155
Project: 3155
Buggy source:
@Override public void run(){
  try {
    player.init();
    long startTime=System.currentTimeMillis();
    while (player.hasNextMessage()) {
      PlayerMessage message=player.getNextMessage();
switch (message.getType()) {
case SENT:
synchronized (sentMessageFieldsMutex) {
          while (sentMessage == null) {
            try {
              sentMessageFieldsMutex.wait();
            }
 catch (            InterruptedException e) {
              if (playerCleared) {
                return;
              }
            }
          }
          String sentMessage=TestConnector.this.sentMessage;
          TestConnector.this.sentMessage=null;
          sentMessageFieldsMutex.notify();
          if (!message.getMessage().equals(sentMessage)) {
            throw new IllegalStateException("String_Node_Str" + sentMessage + "String_Node_Str"+ message.getMessage()+ "String_Node_Str");
          }
        }
      break;
case RECEIVED:
    long period=System.currentTimeMillis() - startTime - message.getTime();
  if (period < 0) {
    try {
      Thread.sleep(-period);
    }
 catch (    InterruptedException e) {
      if (playerCleared) {
        return;
      }
    }
  }
fireMessageReceived(message.getMessage());
break;
}
if (playerCleared) {
return;
}
}
}
  finally {
player.destory();
}
}

Fixed version (ground truth):
@Override public void run(){
  try {
    player.init();
    long startTime=System.currentTimeMillis();
    while (player.hasNextMessage()) {
      PlayerMessage message=player.getNextMessage();
switch (message.getType()) {
case SENT:
synchronized (sentMessageFieldsMutex) {
          while (sentMessage == null) {
            try {
              sentMessageFieldsMutex.wait();
            }
 catch (            InterruptedException e) {
              Thread.currentThread().interrupt();
              return;
            }
          }
          String sentMessage=TestConnector.this.sentMessage;
          TestConnector.this.sentMessage=null;
          sentMessageFieldsMutex.notify();
          if (!message.getMessage().equals(sentMessage)) {
            throw new IllegalStateException("String_Node_Str" + sentMessage + "String_Node_Str"+ message.getMessage()+ "String_Node_Str");
          }
        }
      break;
case RECEIVED:
    long period=System.currentTimeMillis() - startTime - message.getTime();
  if (period < 0) {
    try {
      Thread.sleep(-period);
    }
 catch (    InterruptedException e) {
      Thread.currentThread().interrupt();
      return;
    }
  }
fireMessageReceived(message.getMessage());
break;
}
if (Thread.currentThread().isInterrupted()) {
return;
}
}
}
  finally {
player.destory();
}
}
Program: 3156
Project: 3156
Buggy source:
@Override public void messageSent(ConnectorMessageEvent event){
synchronized (sentMessageFieldsMutex) {
    while (sentMessage != null) {
      try {
        sentMessageFieldsMutex.wait();
      }
 catch (      InterruptedException e) {
        return;
      }
    }
    sentMessage=event.getMessage();
    sentMessageFieldsMutex.notify();
  }
}

Fixed version (ground truth):
@Override public void messageSent(ConnectorMessageEvent event){
  if (event.getMessage().startsWith("String_Node_Str")) {
    return;
  }
synchronized (sentMessageFieldsMutex) {
    while (sentMessage != null) {
      try {
        sentMessageFieldsMutex.wait();
      }
 catch (      InterruptedException e) {
        Thread.currentThread().interrupt();
        return;
      }
    }
    sentMessage=event.getMessage();
    sentMessageFieldsMutex.notify();
  }
}
Program: 3159
Project: 3159
Buggy source:
public void addRecorder(final Recorder recorder) throws ConnectorException {
synchronized (recordingFieldsMutex) {
    Connector.getInstance().connect();
    if (recordListener == null) {
      recordListener=new AbstractConnectorListener(){
        @Override public void messageSent(        ConnectorMessageEvent event){
          long time=System.currentTimeMillis();
          Recorder[] recorders=TestConnector.this.recorders;
          for (          Recorder recorder : recorders) {
            recorder.recordSentMessage(time - recorder.getStartTime(),event.getMessage());
          }
        }
        @Override public void messageReceived(        ConnectorMessageEvent event){
          long time=System.currentTimeMillis();
          Recorder[] recorders=TestConnector.this.recorders;
          for (          Recorder recorder : recorders) {
            recorder.recordReceivedMessage(time - recorder.getStartTime(),event.getMessage());
          }
        }
      }
;
      Connector.getInstance().addConnectorListener(recordListener);
    }
    if (recorderList == null) {
      recorderList=new ArrayList<Recorder>();
    }
    if (!recorderList.contains(recorder)) {
      recorderList.add(recorder);
      recorders=recorderList.toArray(new Recorder[0]);
      if (!recorder.isStarted()) {
        recorder.setStartTime(System.currentTimeMillis());
      }
    }
  }
}

Fixed version (ground truth):
public void addRecorder(final Recorder recorder) throws ConnectorException {
synchronized (recordingFieldsMutex) {
    Connector.getInstance().connect();
    if (recordListener == null) {
      recordListener=new AbstractConnectorListener(){
        @Override public void messageSent(        ConnectorMessageEvent event){
          long time=System.currentTimeMillis();
          Recorder[] recorders=TestConnector.this.recorders;
          for (          Recorder recorder : recorders) {
            recorder.recordSentMessage(time - recorder.getStartTime(),event.getMessage());
          }
        }
        @Override public void messageReceived(        ConnectorMessageEvent event){
          long time=System.currentTimeMillis();
          Recorder[] recorders=TestConnector.this.recorders;
          for (          Recorder recorder : recorders) {
            recorder.recordReceivedMessage(time - recorder.getStartTime(),event.getMessage());
          }
        }
      }
;
      Connector.getInstance().addConnectorListener(recordListener,false,true);
    }
    if (recorderList == null) {
      recorderList=new ArrayList<Recorder>();
    }
    if (!recorderList.contains(recorder)) {
      recorderList.add(recorder);
      recorders=recorderList.toArray(new Recorder[0]);
      if (!recorder.isStarted()) {
        recorder.setStartTime(System.currentTimeMillis());
      }
    }
  }
}
Program: 3160
Project: 3160
Buggy source:
/** 
 * Check if this User has a Skype client that can do video chats.
 * @return true if User can do videochats.
 */
public final boolean isVideoCapable(){
  return Boolean.parseBoolean("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Check if this User has a Skype client that can do video chats.
 * @return true if User can do videochats.
 * @throws SkypeException when connection to Skype client has gone bad. 
 */
public final boolean isVideoCapable() throws SkypeException {
  return Boolean.parseBoolean(getProperty("String_Node_Str"));
}
Program: 3161
Project: 3161
Buggy source:
/** 
 * Initialize the connection to Skype API.
 * @param timeout Wait for this amout of millisecs to initialize.
 */
protected void initialize(int timeout){
  if (!inited) {
    inited=true;
    (new Thread(this)).start();
    setStatus(com.skype.connector.Connector.Status.PENDING_AUTHORIZATION);
    fireMessageReceived("String_Node_Str");
    setDebugPrinting(false);
    init(getApplicationName());
  }
}

Fixed version (ground truth):
/** 
 * Initialize the connection to Skype API.
 * @param timeout Wait for this amout of millisecs to initialize.
 */
protected void initialize(int timeout){
  if (!inited) {
    inited=true;
    if (isSWTAvailable()) {
      try {
        Class displayClass=Class.forName("String_Node_Str");
        Method getCurrentMethod=displayClass.getMethod("String_Node_Str",null);
        Class[] params=new Class[1];
        params[0]=Class.forName("String_Node_Str");
        Method asyncExecMethod=displayClass.getMethod("String_Node_Str",params);
        Object display=getCurrentMethod.invoke(null,null);
        Object[] args=new Object[1];
        args[0]=this;
        asyncExecMethod.invoke(display,args);
      }
 catch (      Throwable e) {
        (new Thread(this)).start();
      }
    }
 else {
      (new Thread(this)).start();
    }
    setStatus(com.skype.connector.Connector.Status.PENDING_AUTHORIZATION);
    fireMessageReceived("String_Node_Str");
    setDebugPrinting(false);
    init(getApplicationName());
  }
}
Program: 3162
Project: 3162
Buggy source:
/** 
 * Add a listener to this connector if the connector is attached.
 * @param listener The listener to add.
 * @param checkAttached if true check if connector is attached.
 * @throws ConnectorException thrown when the connection to the Skype client has gone bad.
 */
protected final void addConnectorListener(final ConnectorListener listener,boolean checkAttached) throws ConnectorException {
  ConnectorUtils.checkNotNull("String_Node_Str",listener);
  listeners.add(ConnectorListener.class,listener);
  if (checkAttached) {
    assureAttached();
  }
}

Fixed version (ground truth):
/** 
 * Add a listener to this connector if the connector is attached.
 * @param listener The listener to add.
 * @param checkAttached if true check if connector is attached.
 * @throws ConnectorException thrown when the connection to the Skype client has gone bad.
 */
public final void addConnectorListener(final ConnectorListener listener,boolean checkAttached) throws ConnectorException {
  ConnectorUtils.checkNotNull("String_Node_Str",listener);
  listeners.add(ConnectorListener.class,listener);
  if (checkAttached) {
    assureAttached();
  }
}
Program: 3163
Project: 3163
Buggy source:
/** 
 * Method to check the attached status of the connector to the Skype Client. If it isn't connected it will connect.
 * @throws ConnectorException thrown when the connection to the Skype client has gone bad.
 */
private void assureAttached() throws ConnectorException {
  Status attachedStatus=getStatus();
  if (attachedStatus != Status.ATTACHED) {
    attachedStatus=connect();
    attachedStatus=getStatus();
    if (attachedStatus != Status.ATTACHED) {
      System.err.println("String_Node_Str" + attachedStatus);
      throw new NotAttachedException(attachedStatus);
    }
  }
}

Fixed version (ground truth):
/** 
 * Method to check the attached status of the connector to the Skype Client. If it isn't connected it will connect.
 * @throws ConnectorException thrown when the connection to the Skype client has gone bad.
 */
private void assureAttached() throws ConnectorException {
  Status attachedStatus=getStatus();
  if (attachedStatus != Status.ATTACHED) {
    attachedStatus=connect();
    if (attachedStatus != Status.ATTACHED) {
      throw new NotAttachedException(attachedStatus);
    }
  }
}
Program: 3164
Project: 3164
Buggy source:
/** 
 * Set the status of this connector instance.
 * @param newValue The new status.
 */
protected final void setStatus(final Status newValue){
  if (status != newValue) {
    status=newValue;
    fireStatusChanged(newValue);
  }
}

Fixed version (ground truth):
/** 
 * Set the status of this connector instance.
 * @param newValue The new status.
 */
protected final void setStatus(final Status newValue){
  status=newValue;
  fireStatusChanged(newValue);
}
Program: 3165
Project: 3165
Buggy source:
public void testNotAvailableAfterTryingToConnect() throws Exception {
  TestUtils.showMessageDialog("String_Node_Str");
  assertEquals(Connector.Status.NOT_AVAILABLE,WindowsConnector.getInstance().connect());
  final boolean[] available=new boolean[1];
  ConnectorListener listener=new AbstractConnectorListener(){
    public void statusChanged(    ConnectorStatusEvent event){
      Connector.Status status=event.getStatus();
      if (status == Connector.Status.API_AVAILABLE) {
        available[0]=true;
      }
    }
  }
;
  WindowsConnector.getInstance().addConnectorListener(listener);
  TestUtils.showMessageDialog("String_Node_Str");
  assertTrue(available[0]);
}

Fixed version (ground truth):
public void testNotAvailableAfterTryingToConnect() throws Exception {
  TestUtils.showMessageDialog("String_Node_Str");
  assertEquals(Connector.Status.NOT_AVAILABLE,WindowsConnector.getInstance().connect());
  final boolean[] available=new boolean[1];
  ConnectorListener listener=new AbstractConnectorListener(){
    public void statusChanged(    ConnectorStatusEvent event){
      Connector.Status status=event.getStatus();
      if (status == Connector.Status.API_AVAILABLE) {
        available[0]=true;
      }
    }
  }
;
  WindowsConnector.getInstance().addConnectorListener(listener,false);
  TestUtils.showMessageDialog("String_Node_Str");
  assertTrue(available[0]);
}
Program: 3166
Project: 3166
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean equals(Object compared){
  if (compared instanceof CallForwardingRule) {
    return toString().equals(((Profile)compared).toString());
  }
  return false;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean equals(Object compared){
  if (compared instanceof CallForwardingRule) {
    return toString().equals(((CallForwardingRule)compared).toString());
  }
  return false;
}
Program: 3168
Project: 3168
Buggy source:
@Override public void run(){
  try {
    player.init();
    long startTime=System.currentTimeMillis();
    while (player.hasNextMessage()) {
      PlayerMessage message=player.getNextMessage();
switch (message.getType()) {
case SENT:
synchronized (sentMessageFieldsMutex) {
          while (sentMessage == null) {
            try {
              sentMessageFieldsMutex.wait();
            }
 catch (            InterruptedException e) {
              if (playerCleared) {
                return;
              }
            }
          }
          String sentMessage=TestConnector.this.sentMessage;
          TestConnector.this.sentMessage=null;
          sentMessageFieldsMutex.notify();
          if (!message.getMessage().equals(sentMessage)) {
            throw new IllegalStateException("String_Node_Str" + sentMessage + "String_Node_Str"+ message.getMessage()+ "String_Node_Str");
          }
        }
      break;
case RECEIVED:
    long period=System.currentTimeMillis() - startTime - message.getTime();
  if (0 < period) {
    try {
      Thread.sleep(period);
    }
 catch (    InterruptedException e) {
      if (playerCleared) {
        return;
      }
    }
  }
fireMessageReceived(message.getMessage());
break;
}
if (playerCleared) {
return;
}
}
}
  finally {
player.destory();
}
}

Fixed version (ground truth):
@Override public void run(){
  try {
    player.init();
    long startTime=System.currentTimeMillis();
    while (player.hasNextMessage()) {
      PlayerMessage message=player.getNextMessage();
switch (message.getType()) {
case SENT:
synchronized (sentMessageFieldsMutex) {
          while (sentMessage == null) {
            try {
              sentMessageFieldsMutex.wait();
            }
 catch (            InterruptedException e) {
              if (playerCleared) {
                return;
              }
            }
          }
          String sentMessage=TestConnector.this.sentMessage;
          TestConnector.this.sentMessage=null;
          sentMessageFieldsMutex.notify();
          if (!message.getMessage().equals(sentMessage)) {
            throw new IllegalStateException("String_Node_Str" + sentMessage + "String_Node_Str"+ message.getMessage()+ "String_Node_Str");
          }
        }
      break;
case RECEIVED:
    long period=System.currentTimeMillis() - startTime - message.getTime();
  if (period < 0) {
    try {
      Thread.sleep(-period);
    }
 catch (    InterruptedException e) {
      if (playerCleared) {
        return;
      }
    }
  }
fireMessageReceived(message.getMessage());
break;
}
if (playerCleared) {
return;
}
}
}
  finally {
player.destory();
}
}
Program: 3169
Project: 3169
Buggy source:
/** 
 * Extract a file for a jarfile on the classpath. Used to extract library files.
 * @param searchString The path+filename to search for.
 * @param filename The file to search and extract.
 * @param destinationDirectory The directory to place it in.
 * @return true if file could be found and extracted.
 */
public static boolean extractFromJar(String searchString,String filename,String destinationDirectory){
  boolean extracted=false;
  String classpath=System.getProperty("String_Node_Str");
  File jarfile=null;
  byte[] buf=new byte[1024];
  String jarFileName;
  StringTokenizer st=new StringTokenizer(classpath,File.pathSeparator);
  while (st.hasMoreTokens() && !extracted) {
    jarFileName=st.nextToken();
    jarfile=new File(jarFileName);
    if (jarfile.exists() && jarfile.isFile()) {
      FileInputStream fis=null;
      try {
        fis=new FileInputStream(jarFileName);
        BufferedInputStream bis=new BufferedInputStream(fis);
        ZipInputStream zis=new ZipInputStream(bis);
        ZipEntry ze=null;
        while ((ze=zis.getNextEntry()) != null) {
          if (ze.getName().endsWith(searchString)) {
            if (!destinationDirectory.endsWith(File.separator)) {
              destinationDirectory=destinationDirectory + File.separator;
            }
            File destFile=new File(destinationDirectory + filename);
            if (destFile.exists()) {
              destFile.delete();
            }
            int n;
            FileOutputStream fileoutputstream;
            fileoutputstream=new FileOutputStream(destinationDirectory + filename);
            while ((n=zis.read(buf,0,1024)) > -1) {
              fileoutputstream.write(buf,0,n);
            }
            fileoutputstream.close();
            extracted=true;
            destFile.deleteOnExit();
          }
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
        extracted=false;
      }
    }
  }
  return extracted;
}

Fixed version (ground truth):
/** 
 * Extract a file from a jarfile on the classpath. Used to extract library files.
 * @param searchString The path+filename to search for.
 * @param filename The file to search and extract.
 * @param destinationDirectory The directory to place it in.
 * @return true if file could be found and extracted.
 */
public static boolean extractFromJar(String searchString,String filename,String destinationDirectory){
  boolean extracted=extractFromJarZipMethod(filename,filename,destinationDirectory);
  if (!extracted) {
    extractFromJarUsingClassLoader(filename,filename,destinationDirectory);
  }
  return extracted;
}
Program: 3170
Project: 3170
Buggy source:
/** 
 * Search for a file in the jars of the classpath, return true if found.
 * @param searchString The path+filename to search for.
 * @return true if file could be found.
 */
public static boolean isInJar(String searchString){
  boolean found=false;
  String classpath=System.getProperty("String_Node_Str");
  File jarfile=null;
  String jarFileName;
  StringTokenizer st=new StringTokenizer(classpath,File.pathSeparator);
  while (st.hasMoreTokens() && !found) {
    jarFileName=st.nextToken();
    jarfile=new File(jarFileName);
    if (jarfile.exists() && jarfile.isFile()) {
      FileInputStream fis=null;
      try {
        fis=new FileInputStream(jarFileName);
        BufferedInputStream bis=new BufferedInputStream(fis);
        ZipInputStream zis=new ZipInputStream(bis);
        ZipEntry ze=null;
        while ((ze=zis.getNextEntry()) != null) {
          if (ze.getName().endsWith(searchString)) {
            found=true;
          }
        }
      }
 catch (      Exception e) {
        found=false;
      }
    }
  }
  return found;
}

Fixed version (ground truth):
/** 
 * Search for a file in the jars of the classpath, return true if found.
 * @param searchString The path+filename to search for.
 * @return true if file could be found.
 */
public static boolean isInJar(String searchString){
  boolean found=false;
  String classpath=getExtendedClasspath();
  File jarfile=null;
  String jarFileName;
  StringTokenizer st=new StringTokenizer(classpath,File.pathSeparator);
  while (st.hasMoreTokens() && !found) {
    jarFileName=st.nextToken();
    jarfile=new File(jarFileName);
    if (jarfile.exists() && jarfile.isFile()) {
      FileInputStream fis=null;
      try {
        fis=new FileInputStream(jarFileName);
        BufferedInputStream bis=new BufferedInputStream(fis);
        ZipInputStream zis=new ZipInputStream(bis);
        ZipEntry ze=null;
        while ((ze=zis.getNextEntry()) != null) {
          if (ze.getName().endsWith(searchString)) {
            found=true;
          }
        }
      }
 catch (      Exception e) {
        found=false;
      }
    }
  }
  return found;
}
Program: 3171
Project: 3171
Buggy source:
/** 
 * Private constructor to keep this a singleton. Use getInstance to get an instance.
 */
private LinuxConnector(){
  try {
    System.loadLibrary("String_Node_Str");
  }
 catch (  Exception e) {
    try {
      if (!Utils.checkLibraryInPath(LIBFILENAME)) {
        Utils.extractFromJarToTemp(LIBFILENAME);
        System.load(System.getProperty("String_Node_Str") + File.separatorChar + LIBFILENAME);
      }
    }
 catch (    Exception e2) {
      setStatus(Status.NOT_AVAILABLE);
      fireMessageReceived(CONNECTOR_STATUS_CHANGED);
    }
  }
  setStatus(Status.PENDING_AUTHORIZATION);
  fireMessageReceived(CONNECTOR_STATUS_CHANGED);
}

Fixed version (ground truth):
/** 
 * Private constructor to keep this a singleton. Use getInstance to get an instance.
 */
private LinuxConnector(){
  try {
    System.loadLibrary("String_Node_Str");
  }
 catch (  Throwable e) {
    try {
      if (!Utils.checkLibraryInPath(LIBFILENAME)) {
        Utils.extractFromJarToTemp(LIBFILENAME);
        System.load(System.getProperty("String_Node_Str") + File.separatorChar + LIBFILENAME);
      }
    }
 catch (    Exception e2) {
      setStatus(Status.NOT_AVAILABLE);
      fireMessageReceived(CONNECTOR_STATUS_CHANGED);
    }
  }
  setStatus(Status.PENDING_AUTHORIZATION);
  fireMessageReceived(CONNECTOR_STATUS_CHANGED);
}
Program: 3172
Project: 3172
Buggy source:
@Override protected void initialize(int timeout){
  try {
    System.loadLibrary("String_Node_Str");
  }
 catch (  Exception e) {
    if (!Utils.checkLibraryInPath(LIBFILENAME)) {
      Utils.extractFromJarToTemp(LIBFILENAME);
      System.load(System.getProperty("String_Node_Str") + File.separatorChar + LIBFILENAME);
    }
  }
  jni_init();
  thread_=new Thread(new Runnable(){
    public void run(){
      jni_windowProc();
    }
  }
,"String_Node_Str");
  thread_.setDaemon(true);
  thread_.start();
}

Fixed version (ground truth):
@Override protected void initialize(int timeout){
  try {
    System.loadLibrary("String_Node_Str");
  }
 catch (  Throwable e) {
    if (!Utils.checkLibraryInPath(LIBFILENAME)) {
      Utils.extractFromJarToTemp(LIBFILENAME);
      System.load(System.getProperty("String_Node_Str") + File.separatorChar + LIBFILENAME);
    }
  }
  jni_init();
  thread_=new Thread(new Runnable(){
    public void run(){
      jni_windowProc();
    }
  }
,"String_Node_Str");
  thread_.setDaemon(true);
  thread_.start();
}
Program: 3173
Project: 3173
Buggy source:
public void messageReceived(final String message){
  final String dataHeader="String_Node_Str" + getName() + "String_Node_Str";
  if (isStreamMessage(message)) {
    String streamIds=message.substring(("String_Node_Str" + getName() + "String_Node_Str").length());
    if (!"String_Node_Str".equals(streamIds)) {
      for (      String streamId : streamIds.split("String_Node_Str")) {
        if (streams.containsKey(streamId)) {
          continue;
        }
        int delimiterIndex=streamId.indexOf(':');
        String friendId=streamId.substring(0,delimiterIndex);
        Friend friend;
        try {
          friend=Skype.getContactList().getFriend(friendId);
        }
 catch (        SkypeException e) {
          throw new IllegalStateException("String_Node_Str" + friendId);
        }
        int number=Integer.parseInt(streamId.substring(delimiterIndex + 1));
        Stream stream=new Stream(Application.this,friend,number);
        streams.put(streamId,stream);
        fireConnected(stream);
      }
    }
    NEXT:     for (    String existedStreamId : streams.keySet()) {
      if (!"String_Node_Str".equals(streamIds)) {
        for (        String streamId : streamIds.split("String_Node_Str")) {
          if (existedStreamId.equals(streamId)) {
            continue NEXT;
          }
        }
      }
      fireDisconnected(streams.get(existedStreamId));
    }
  }
  if (message.startsWith(dataHeader)) {
    handleData(message.substring(dataHeader.length()));
  }
}

Fixed version (ground truth):
public void messageReceived(final String message){
  String streamsHeader="String_Node_Str" + getName() + "String_Node_Str";
  if (message.startsWith(streamsHeader)) {
    String streamIds=message.substring(streamsHeader.length());
    fireStreamEvents(streamIds);
  }
  final String dataHeader="String_Node_Str" + getName() + "String_Node_Str";
  if (message.startsWith(dataHeader)) {
    handleData(message.substring(dataHeader.length()));
  }
}
Program: 3174
Project: 3174
Buggy source:
public void finish() throws SkypeException {
synchronized (isFinishedFieldMutex) {
    if (!isFinished) {
      try {
        String response=Connector.getInstance().execute("String_Node_Str" + getName());
        Utils.checkError(response);
      }
 catch (      ConnectorException e) {
        Utils.convertToSkypeException(e);
      }
      Connector.getInstance().removeConnectorMessageReceivedListener(dataListener);
      Runtime.getRuntime().removeShutdownHook(shutdownHookForFinish);
      isFinished=true;
    }
  }
}

Fixed version (ground truth):
public void finish() throws SkypeException {
synchronized (isFinishedFieldMutex) {
    if (!isFinished) {
      Connector.getInstance().removeConnectorMessageReceivedListener(dataListener);
      Runtime.getRuntime().removeShutdownHook(shutdownHookForFinish);
      isFinished=true;
      try {
        String response=Connector.getInstance().execute("String_Node_Str" + getName());
        Utils.checkError(response);
      }
 catch (      ConnectorException e) {
        Utils.convertToSkypeException(e);
      }
    }
  }
}
Program: 3175
Project: 3175
Buggy source:
void initialize() throws SkypeException {
  try {
    String createResponse=Connector.getInstance().execute("String_Node_Str" + name);
    try {
      Utils.checkError(createResponse);
    }
 catch (    SkypeException e) {
      String deleteResponse=Connector.getInstance().execute("String_Node_Str" + getName());
      Utils.checkError(deleteResponse);
      String retryResponse=Connector.getInstance().execute("String_Node_Str" + name);
      Utils.checkError(retryResponse);
    }
    Connector.getInstance().addConnectorMessageReceivedListener(dataListener);
    shutdownHookForFinish=new Thread(){
      @Override public void run(){
        try {
          Connector.getInstance().execute("String_Node_Str" + Application.this.getName());
        }
 catch (        ConnectorException e) {
        }
      }
    }
;
    Runtime.getRuntime().addShutdownHook(shutdownHookForFinish);
  }
 catch (  ConnectorException e) {
    Utils.convertToSkypeException(e);
  }
}

Fixed version (ground truth):
void initialize() throws SkypeException {
  try {
    String response=Connector.getInstance().execute("String_Node_Str" + name);
    Utils.checkError(response);
    Connector.getInstance().addConnectorMessageReceivedListener(dataListener);
    shutdownHookForFinish=new Thread(){
      @Override public void run(){
        try {
          Connector.getInstance().execute("String_Node_Str" + Application.this.getName());
        }
 catch (        ConnectorException e) {
        }
      }
    }
;
    Runtime.getRuntime().addShutdownHook(shutdownHookForFinish);
  }
 catch (  ConnectorException e) {
    Utils.convertToSkypeException(e);
  }
}
Program: 3176
Project: 3176
Buggy source:
private void handleData(String dataResponse){
  try {
    if (isReceivedText(dataResponse)) {
      String data=dataResponse.substring("String_Node_Str".length());
      String streamId=data.substring(0,data.indexOf('='));
      String dataHeader="String_Node_Str" + getName() + "String_Node_Str"+ streamId;
      String response=Connector.getInstance().executeWithId(dataHeader,dataHeader);
      Utils.checkError(response);
      String text=response.substring(dataHeader.length() + 1);
      streams.get(streamId).fireTextReceived(text);
    }
 else     if (isReceivedDatagram(dataResponse)) {
      String data=dataResponse.substring("String_Node_Str".length());
      String streamId=data.substring(0,data.indexOf(' '));
      String datagram=data.substring(data.indexOf(' ') + 1);
      streams.get(streamId).fireDatagramReceived(datagram);
    }
  }
 catch (  Exception e) {
    throw new IllegalStateException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void handleData(String dataResponse){
  try {
    if (isReceivedText(dataResponse)) {
      String data=dataResponse.substring("String_Node_Str".length());
      String streamId=data.substring(0,data.indexOf('='));
      String dataHeader="String_Node_Str" + getName() + "String_Node_Str"+ streamId;
      String response=Connector.getInstance().executeWithId(dataHeader,dataHeader);
      Utils.checkError(response);
      String text=response.substring(dataHeader.length() + 1);
synchronized (streams) {
        if (streams.containsKey(streamId)) {
          streams.get(streamId).fireTextReceived(text);
        }
      }
    }
 else     if (isReceivedDatagram(dataResponse)) {
      String data=dataResponse.substring("String_Node_Str".length());
      String streamId=data.substring(0,data.indexOf(' '));
      String datagram=data.substring(data.indexOf(' ') + 1);
synchronized (streams) {
        if (streams.containsKey(streamId)) {
          streams.get(streamId).fireDatagramReceived(datagram);
        }
      }
    }
  }
 catch (  Exception e) {
    throw new IllegalStateException("String_Node_Str",e);
  }
}
Program: 3177
Project: 3177
Buggy source:
public Stream connect(final Friend friend) throws SkypeException {
  Utils.checkNotNull("String_Node_Str",friend);
  try {
    final String[] id=new String[1];
    final String[] error=new String[1];
    MessageProcessor processor=new MessageProcessor(){
      public void messageReceived(      String message){
        if (message.equals("String_Node_Str" + getName() + "String_Node_Str"+ friend.getId())) {
        }
 else         if (message.equals("String_Node_Str" + getName() + "String_Node_Str")) {
        }
 else         if (message.startsWith("String_Node_Str" + getName() + "String_Node_Str")) {
          id[0]=message.substring(("String_Node_Str" + getName() + "String_Node_Str").length());
          releaseLock();
        }
 else         if (message.startsWith("String_Node_Str")) {
          error[0]=message.substring("String_Node_Str".length());
          releaseLock();
        }
      }
    }
;
    Connector.getInstance().execute("String_Node_Str" + getName() + "String_Node_Str"+ friend.getId(),processor);
    Utils.checkError(error[0]);
    return streams.get(id[0]);
  }
 catch (  ConnectorException e) {
    Utils.convertToSkypeException(e);
    return null;
  }
}

Fixed version (ground truth):
public Stream[] connect(Friend... friends) throws SkypeException {
  Utils.checkNotNull("String_Node_Str",friends);
synchronized (connectMutex) {
    try {
      final Object wait=new Object();
      ConnectorMessageReceivedListener connectorListener=new ConnectorMessageReceivedListener(){
        public void messageReceived(        String receivedMessage){
          if (receivedMessage.equals("String_Node_Str" + getName() + "String_Node_Str")) {
synchronized (wait) {
              wait.notify();
            }
          }
        }
      }
;
      try {
        Connector.getInstance().addConnectorMessageReceivedListener(connectorListener);
synchronized (wait) {
          for (          Friend friend : friends) {
            String result=Connector.getInstance().execute("String_Node_Str" + getName() + "String_Node_Str"+ friend.getId());
            Utils.checkError(result);
          }
          try {
            wait.wait();
          }
 catch (          InterruptedException e) {
            throw new SkypeException("String_Node_Str",e);
          }
        }
        return getAllStreams(friends);
      }
 catch (      ConnectorException e) {
        Utils.convertToSkypeException(e);
        return null;
      }
 finally {
        Connector.getInstance().removeConnectorMessageReceivedListener(connectorListener);
      }
    }
 catch (    SkypeException e) {
      for (      Stream stream : getAllStreams(friends)) {
        try {
          stream.disconnect();
        }
 catch (        SkypeException e2) {
        }
      }
      throw e;
    }
  }
}
Program: 3178
Project: 3178
Buggy source:
SkypeException(String message){
  super(message);
}

Fixed version (ground truth):
SkypeException(String message,Throwable cause){
  super(message,cause);
}
Program: 3179
Project: 3179
Buggy source:
public void disconnect() throws SkypeException {
  try {
    String response=Connector.getInstance().execute("String_Node_Str" + application.getName() + "String_Node_Str"+ friend.getId()+ "String_Node_Str");
    Utils.checkError(response);
    application.fireDisconnected(this);
  }
 catch (  ConnectorException e) {
    Utils.convertToSkypeException(e);
  }
}

Fixed version (ground truth):
public void disconnect() throws SkypeException {
  try {
    String response=Connector.getInstance().execute("String_Node_Str" + application.getName() + "String_Node_Str"+ getId());
    Utils.checkError(response);
    application.fireDisconnected(this);
  }
 catch (  ConnectorException e) {
    Utils.convertToSkypeException(e);
  }
}
Program: 3180
Project: 3180
Buggy source:
public Friend getFriend(){
  return friend;
}

Fixed version (ground truth):
public Friend getFriend(){
  return new Friend(getId().substring(0,getId().indexOf(':')));
}
Program: 3181
Project: 3181
Buggy source:
public String getId(){
  return getFriend().getId() + "String_Node_Str" + getNumber();
}

Fixed version (ground truth):
public String getId(){
  return id;
}
Program: 3182
Project: 3182
Buggy source:
Stream(Application application,Friend friend,int number){
}

Fixed version (ground truth):
Stream(Application application,String id){
}
Program: 3183
Project: 3183
Buggy source:
public void testWriteOnMultiThread() throws Exception {
  Skype.setDebug(true);
  Application application=Skype.addApplication(APPLICATION_NAME);
  Friend friend=TestData.getFriend();
  try {
    Stream stream=application.connect(friend);
    checkConnectedFriends(application,friend);
    checkWriteOnMultiThread(stream);
    checkDisconnect(application,stream);
  }
  finally {
    application.finish();
  }
}

Fixed version (ground truth):
public void testWriteOnMultiThread() throws Exception {
  Skype.setDebug(true);
  Application application=Skype.addApplication(APPLICATION_NAME);
  Friend friend=TestData.getFriend();
  try {
    Stream[] streams=application.connect(friend);
    assertEquals(1,streams.length);
    Stream stream=streams[0];
    checkConnectedFriends(application,friend);
    checkWriteOnMultiThread(stream);
    checkDisconnect(application,stream);
  }
  finally {
    application.finish();
  }
}
Program: 3184
Project: 3184
Buggy source:
public void testApplication() throws Exception {
  Skype.setDebug(true);
  Application application=Skype.addApplication(APPLICATION_NAME);
  Friend friend=TestData.getFriend();
  checkConnectableFriendsBeforeConnecting(application);
  try {
    Stream stream=application.connect(friend);
    checkConnectableFriendsAfterConnecting(application);
    checkConnectedFriends(application,friend);
    checkWrite(stream);
    checkSend(stream);
    checkDisconnect(application,stream);
  }
  finally {
    application.finish();
  }
}

Fixed version (ground truth):
public void testApplication() throws Exception {
  Skype.setDebug(true);
  Application application=Skype.addApplication(APPLICATION_NAME);
  Friend friend=TestData.getFriend();
  checkConnectableFriendsBeforeConnecting(application);
  try {
    Stream[] streams=application.connect(friend);
    assertEquals(1,streams.length);
    Stream stream=streams[0];
    checkConnectableFriendsAfterConnecting(application);
    checkConnectedFriends(application,friend);
    checkWrite(stream);
    checkSend(stream);
    checkDisconnect(application,stream);
  }
  finally {
    application.finish();
  }
}
Program: 3185
Project: 3185
Buggy source:
public static Application addApplication(String name) throws SkypeException {
  Application application=new Application(name);
  application.initialize();
  return application;
}

Fixed version (ground truth):
public static Application addApplication(String name) throws SkypeException {
  Application application=new Application(name);
  application.initalize();
  return application;
}
Program: 3187
Project: 3187
Buggy source:
public boolean isWifi(Context context){
  ConnectivityManager cm=(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo info=cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
  if (info == null) {
    return false;
  }
 else {
    return info.isConnectedOrConnecting();
  }
}

Fixed version (ground truth):
public boolean isWifi(Context context){
  ConnectivityManager cm=(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo info=cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
  if (info == null) {
    return false;
  }
 else {
    return info.isConnected();
  }
}
Program: 3189
Project: 3189
Buggy source:
public boolean isOnline(Context context){
  ConnectivityManager cm=(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo info=cm.getActiveNetworkInfo();
  if (info == null) {
    return false;
  }
 else {
    return info.isConnectedOrConnecting();
  }
}

Fixed version (ground truth):
public boolean isOnline(Context context){
  ConnectivityManager cm=(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo info=cm.getActiveNetworkInfo();
  if (info == null) {
    return false;
  }
 else {
    return info.isConnected();
  }
}
Program: 3193
Project: 3193
Buggy source:
@Override protected void fillRemoteViews(RemoteViews updateViews,Context context,int widgetId,int error){
switch (error) {
case UpdateWidgetService.NONE:
case UpdateWidgetService.NETWORK:
    List<Line> lines=buildLines(context);
  int[] lineViews={R.id.widget2x2_line2,R.id.widget2x2_line3,R.id.widget2x2_line4,R.id.widget2x2_line5,R.id.widget2x2_line6,R.id.widget2x2_line7,R.id.widget2x2_line8,R.id.widget2x2_line9};
Log.d(TAG,Integer.toString(lines.size()));
for (int n=0; n < lineViews.length; n++) {
if (n >= lines.size()) {
  break;
}
SpannableString formattedLine=new SpannableString(lines.get(n).getLineContent());
if (lines.get(n).getSize() != -1) {
  formattedLine.setSpan(new AbsoluteSizeSpan(Util.dpToPx(context,lines.get(n).getSize())),0,formattedLine.length(),0);
}
 else {
  formattedLine.setSpan(new AbsoluteSizeSpan(Util.dpToPx(context,NORMALSIZE)),0,formattedLine.length(),0);
}
updateViews.setTextViewText(lineViews[n],formattedLine);
}
updateViews.setTextViewText(R.id.widget2x2_line1,getUpdateDateString(context));
break;
case UpdateWidgetService.LOGINFAILED:
updateViews.setTextViewText(R.id.widget2x2_line1,"String_Node_Str");
break;
case UpdateWidgetService.USERNAMEPASSWORD:
updateViews.setTextViewText(R.id.widget2x2_line1,"String_Node_Str");
break;
}
Intent viewIntent=new Intent(context,MainActivity.class);
PendingIntent pending=PendingIntent.getActivity(context,0,viewIntent,0);
updateViews.setOnClickPendingIntent(R.id.widget2x2_widget,pending);
}

Fixed version (ground truth):
@Override protected void fillRemoteViews(RemoteViews updateViews,Context context,int widgetId,int error){
switch (error) {
case UpdateWidgetService.NONE:
case UpdateWidgetService.NETWORK:
    List<Line> lines=buildLines(context);
  int[] lineViews={R.id.widget2x2_line2,R.id.widget2x2_line3,R.id.widget2x2_line4,R.id.widget2x2_line5,R.id.widget2x2_line6,R.id.widget2x2_line7,R.id.widget2x2_line8,R.id.widget2x2_line9};
for (int line : lineViews) {
  updateViews.setTextViewText(line,"String_Node_Str");
}
Log.d(TAG,Integer.toString(lines.size()));
for (int n=0; n < lineViews.length; n++) {
if (n >= lines.size()) {
break;
}
SpannableString formattedLine=new SpannableString(lines.get(n).getLineContent());
if (lines.get(n).getSize() != -1) {
formattedLine.setSpan(new AbsoluteSizeSpan(Util.dpToPx(context,lines.get(n).getSize())),0,formattedLine.length(),0);
}
 else {
formattedLine.setSpan(new AbsoluteSizeSpan(Util.dpToPx(context,NORMALSIZE)),0,formattedLine.length(),0);
}
updateViews.setTextViewText(lineViews[n],formattedLine);
}
updateViews.setTextViewText(R.id.widget2x2_line1,getUpdateDateString(context));
break;
case UpdateWidgetService.LOGINFAILED:
updateViews.setTextViewText(R.id.widget2x2_line1,"String_Node_Str");
break;
case UpdateWidgetService.USERNAMEPASSWORD:
updateViews.setTextViewText(R.id.widget2x2_line1,"String_Node_Str");
break;
}
Intent viewIntent=new Intent(context,MainActivity.class);
PendingIntent pending=PendingIntent.getActivity(context,0,viewIntent,0);
updateViews.setOnClickPendingIntent(R.id.widget2x2_widget,pending);
}
Program: 3194
Project: 3194
Buggy source:
public QuickFindBox() throws Exception {
  super();
  searchEntryField=new TextField(INPUT_QUERY_CSS);
  accounts=new ClickableElement("String_Node_Str");
}

Fixed version (ground truth):
public QuickFindBox() throws Exception {
  super();
  searchEntryField=new TextField(INPUT_QUERY_CSS);
  accountsMenuItem=new ClickableElement("String_Node_Str");
}
Program: 3195
Project: 3195
Buggy source:
private static DefaultSelenium launchStaticSeleniumBrowser(){
  try {
    SeleniumProxySingleton.makeSureWeHaveAJettyProxyRunning();
    seleniumSingleton=new DefaultSelenium(SeleniumProxySingleton.SELENIUM_SERVER_HOST,SeleniumProxySingleton.SELENIUM_SERVER_PORT,getBrowserForTesting(),DashBoard.FFCRM_DOMAIN);
    seleniumSingleton.start();
    seleniumSingleton.setSpeed("String_Node_Str");
    seleniumSingleton.setTimeout(STANDARD_PAGE_LOAD_WAIT_TIME);
    seleniumSingleton.windowMaximize();
    return seleniumSingleton;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
private static DefaultSelenium launchStaticSeleniumBrowser(){
  try {
    SeleniumProxySingleton.makeSureWeHaveAJettyProxyRunning();
    seleniumSingleton=new DefaultSelenium(SeleniumProxySingleton.SELENIUM_SERVER_HOST,SeleniumProxySingleton.SELENIUM_SERVER_PORT,getBrowserForTesting(),DashBoard.FFCRM_DOMAIN){
      @Override public void open(      final String url){
        commandProcessor.doCommand("String_Node_Str",new String[]{url,"String_Node_Str"});
      }
    }
;
    seleniumSingleton.start();
    seleniumSingleton.setSpeed("String_Node_Str");
    seleniumSingleton.setTimeout(STANDARD_PAGE_LOAD_WAIT_TIME);
    seleniumSingleton.windowMaximize();
    return seleniumSingleton;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
Program: 3196
Project: 3196
Buggy source:
private static SeleniumServer getInstance() throws Exception, IOException {
  Socket socket=null;
  try {
    socket=new Socket(SELENIUM_SERVER_HOST,SELENIUM_SERVER_PORT);
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + SELENIUM_SERVER_PORT);
    System.out.println("String_Node_Str" + SELENIUM_SERVER_PORT);
    jettyProxyInstance=startJettyProxy();
    jettyProxyWasStartedByATest=true;
  }
 finally {
    if (socket != null)     socket.close();
  }
  return jettyProxyInstance;
}

Fixed version (ground truth):
private static SeleniumServer getInstance() throws Exception, IOException {
  Socket socket=null;
  try {
    socket=checkWhetherPortIsInUse();
  }
 catch (  Exception e) {
    launchJettyProxy();
  }
 finally {
    if (socket != null)     socket.close();
  }
  return jettyProxyInstance;
}
Program: 3197
Project: 3197
Buggy source:
@Test public void canFindExistingAccount() throws Exception {
  QuickFindBox quickFind=(QuickFindBox)CommonComponents.topRightLinks.quickFind.clickToNewContainer();
  quickFind.accounts.click();
  AccountPage huckabiesPage=(AccountPage)quickFind.searchForAccount("String_Node_Str",AccountPage.class);
  assertTrue(huckabiesPage.title.reads("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void canFindExistingAccount() throws Exception {
  QuickFindBox quickFind=(QuickFindBox)CommonComponents.topRightLinks.quickFind.clickToNewContainer();
  quickFind.accountsMenuItem.click();
  AccountPage huckabiesPage=(AccountPage)quickFind.searchForAccount("String_Node_Str",AccountPage.class);
  assertTrue(huckabiesPage.title.reads("String_Node_Str"));
}
Program: 3201
Project: 3201
Buggy source:
void map(AnnotatedType<?> annotatedType,JcrNode jcrNode){
  OCMMapping mapping=new OCMMapping();
  mapping.setNodeType(jcrNode.value());
  Class<?> clazz=(Class<?>)annotatedType.getBaseType();
  Field[] fields=clazz.getDeclaredFields();
  mapping.setNodeClass(clazz);
  for (  Field field : fields) {
    logger.debugf("String_Node_Str",field.getName());
    String fieldName=field.getName();
    String prop=field.getName();
    JcrProperty property=field.getAnnotation(JcrProperty.class);
    if (property != null) {
      prop=property.value();
    }
    logger.debugf("String_Node_Str",fieldName,prop);
    mapping.getPropertiesToFields().put(prop,field);
    mapping.getFieldsToProperties().put(fieldName,prop);
  }
  addMapping(mapping);
}

Fixed version (ground truth):
void map(AnnotatedType<?> annotatedType,JcrNode jcrNode){
  OCMMapping mapping=new OCMMapping();
  mapping.setNodeType(jcrNode.value());
  Class<?> clazz=(Class<?>)annotatedType.getBaseType();
  Field[] fields=clazz.getDeclaredFields();
  Method[] methods=clazz.getMethods();
  mapping.setNodeClass(clazz);
  Map<String,JcrProperty> properties=new HashMap<String,JcrProperty>();
  for (  Method method : methods) {
    if (method.isAnnotationPresent(JcrProperty.class)) {
      String fieldName=getterToFieldName(method.getName());
      properties.put(fieldName,method.getAnnotation(JcrProperty.class));
    }
  }
  for (  Field field : fields) {
    logger.debugf("String_Node_Str",field.getName());
    String fieldName=field.getName();
    String prop=field.getName();
    JcrProperty property=field.getAnnotation(JcrProperty.class);
    if (property != null) {
      prop=property.value();
    }
 else     if (properties.containsKey(prop)) {
      prop=properties.get(prop).value();
    }
    logger.debugf("String_Node_Str",fieldName,prop);
    mapping.getPropertiesToFields().put(prop,field);
    mapping.getFieldsToProperties().put(fieldName,prop);
  }
  addMapping(mapping);
}