nus-yam/ex-repair huggingface dataset:
Program: 43261
Project: 43261
Buggy source:
public void removeTestProvider(String provider){
  checkMockPermissionsSafe();
synchronized (mLock) {
    MockProvider mockProvider=mMockProviders.get(provider);
    if (mockProvider == null) {
      throw new IllegalArgumentException("String_Node_Str" + provider + "String_Node_Str");
    }
    removeProvider(mProvidersByName.get(provider));
    mMockProviders.remove(mockProvider);
    updateProvidersLocked();
  }
}

Fixed version (ground truth):
public void removeTestProvider(String provider){
  checkMockPermissionsSafe();
synchronized (mLock) {
    MockProvider mockProvider=mMockProviders.get(provider);
    if (mockProvider == null) {
      throw new IllegalArgumentException("String_Node_Str" + provider + "String_Node_Str");
    }
    removeProvider(mProvidersByName.get(provider));
    mMockProviders.remove(mockProvider);
    if (LocationManager.GPS_PROVIDER.equals(provider) && mGpsLocationProvider != null) {
      addProvider(mGpsLocationProvider);
    }
 else     if (LocationManager.NETWORK_PROVIDER.equals(provider) && mNetworkLocationProvider != null) {
      addProvider(mNetworkLocationProvider);
    }
    mLastKnownLocation.put(provider,null);
    updateProvidersLocked();
  }
}
Program: 43262
Project: 43262
Buggy source:
private void _loadProvidersLocked(){
  if (GpsLocationProvider.isSupported()) {
    GpsLocationProvider provider=new GpsLocationProvider(mContext,this);
    mGpsStatusProvider=provider.getGpsStatusProvider();
    LocationProviderProxy proxy=new LocationProviderProxy(LocationManager.GPS_PROVIDER,provider);
    addProvider(proxy);
  }
  updateProvidersLocked();
}

Fixed version (ground truth):
private void _loadProvidersLocked(){
  if (GpsLocationProvider.isSupported()) {
    GpsLocationProvider provider=new GpsLocationProvider(mContext,this);
    mGpsStatusProvider=provider.getGpsStatusProvider();
    LocationProviderProxy proxy=new LocationProviderProxy(LocationManager.GPS_PROVIDER,provider);
    addProvider(proxy);
    mGpsLocationProvider=proxy;
  }
  updateProvidersLocked();
}
Program: 43263
Project: 43263
Buggy source:
public void installLocationProvider(String name,ILocationProvider provider){
  if (mContext.checkCallingOrSelfPermission(INSTALL_LOCATION_PROVIDER) != PackageManager.PERMISSION_GRANTED) {
    throw new SecurityException("String_Node_Str");
  }
synchronized (mLock) {
    LocationProviderProxy oldProvider=mProvidersByName.get(name);
    if (oldProvider != null) {
      if (oldProvider.isDead()) {
        Log.d(TAG,"String_Node_Str");
        removeProvider(oldProvider);
      }
 else {
        throw new IllegalArgumentException("String_Node_Str" + name + "String_Node_Str");
      }
    }
    LocationProviderProxy proxy=new LocationProviderProxy(name,provider);
    addProvider(proxy);
    updateProvidersLocked();
    proxy.updateNetworkState(mNetworkState);
  }
}

Fixed version (ground truth):
public void installLocationProvider(String name,ILocationProvider provider){
  if (mContext.checkCallingOrSelfPermission(INSTALL_LOCATION_PROVIDER) != PackageManager.PERMISSION_GRANTED) {
    throw new SecurityException("String_Node_Str");
  }
synchronized (mLock) {
    LocationProviderProxy oldProvider=mProvidersByName.get(name);
    if (oldProvider != null) {
      if (oldProvider.isDead()) {
        Log.d(TAG,"String_Node_Str");
        removeProvider(oldProvider);
      }
 else {
        throw new IllegalArgumentException("String_Node_Str" + name + "String_Node_Str");
      }
    }
    LocationProviderProxy proxy=new LocationProviderProxy(name,provider);
    addProvider(proxy);
    updateProvidersLocked();
    if (LocationManager.NETWORK_PROVIDER.equals(name)) {
      mNetworkLocationProvider=proxy;
    }
    proxy.updateNetworkState(mNetworkState);
  }
}
Program: 43264
Project: 43264
Buggy source:
public void addTestProvider(String name,boolean requiresNetwork,boolean requiresSatellite,boolean requiresCell,boolean hasMonetaryCost,boolean supportsAltitude,boolean supportsSpeed,boolean supportsBearing,int powerRequirement,int accuracy){
  checkMockPermissionsSafe();
synchronized (mLock) {
    MockProvider provider=new MockProvider(name,this,requiresNetwork,requiresSatellite,requiresCell,hasMonetaryCost,supportsAltitude,supportsSpeed,supportsBearing,powerRequirement,accuracy);
    if (mProvidersByName.get(name) != null) {
      throw new IllegalArgumentException("String_Node_Str" + name + "String_Node_Str");
    }
    long identity=Binder.clearCallingIdentity();
    addProvider(new LocationProviderProxy(name,provider));
    mMockProviders.put(name,provider);
    updateProvidersLocked();
    Binder.restoreCallingIdentity(identity);
  }
}

Fixed version (ground truth):
public void addTestProvider(String name,boolean requiresNetwork,boolean requiresSatellite,boolean requiresCell,boolean hasMonetaryCost,boolean supportsAltitude,boolean supportsSpeed,boolean supportsBearing,int powerRequirement,int accuracy){
  checkMockPermissionsSafe();
synchronized (mLock) {
    MockProvider provider=new MockProvider(name,this,requiresNetwork,requiresSatellite,requiresCell,hasMonetaryCost,supportsAltitude,supportsSpeed,supportsBearing,powerRequirement,accuracy);
    if (LocationManager.GPS_PROVIDER.equals(name) || LocationManager.NETWORK_PROVIDER.equals(name)) {
      LocationProviderProxy proxy=mProvidersByName.get(name);
      if (proxy != null) {
        proxy.enableLocationTracking(false);
        removeProvider(proxy);
      }
    }
    if (mProvidersByName.get(name) != null) {
      throw new IllegalArgumentException("String_Node_Str" + name + "String_Node_Str");
    }
    addProvider(new LocationProviderProxy(name,provider));
    mMockProviders.put(name,provider);
    mLastKnownLocation.put(name,null);
    updateProvidersLocked();
  }
}
Program: 43265
Project: 43265
Buggy source:
public void removeTestProvider(String provider){
  checkMockPermissionsSafe();
synchronized (mLock) {
    MockProvider mockProvider=mMockProviders.get(provider);
    if (mockProvider == null) {
      throw new IllegalArgumentException("String_Node_Str" + provider + "String_Node_Str");
    }
    removeProvider(mProvidersByName.get(provider));
    mMockProviders.remove(mockProvider);
    updateProvidersLocked();
  }
}

Fixed version (ground truth):
public void removeTestProvider(String provider){
  checkMockPermissionsSafe();
synchronized (mLock) {
    MockProvider mockProvider=mMockProviders.get(provider);
    if (mockProvider == null) {
      throw new IllegalArgumentException("String_Node_Str" + provider + "String_Node_Str");
    }
    removeProvider(mProvidersByName.get(provider));
    mMockProviders.remove(mockProvider);
    if (LocationManager.GPS_PROVIDER.equals(provider) && mGpsLocationProvider != null) {
      addProvider(mGpsLocationProvider);
    }
 else     if (LocationManager.NETWORK_PROVIDER.equals(provider) && mNetworkLocationProvider != null) {
      addProvider(mNetworkLocationProvider);
    }
    mLastKnownLocation.put(provider,null);
    updateProvidersLocked();
  }
}
Program: 43266
Project: 43266
Buggy source:
private void _loadProvidersLocked(){
  if (GpsLocationProvider.isSupported()) {
    GpsLocationProvider provider=new GpsLocationProvider(mContext,this);
    mGpsStatusProvider=provider.getGpsStatusProvider();
    LocationProviderProxy proxy=new LocationProviderProxy(LocationManager.GPS_PROVIDER,provider);
    addProvider(proxy);
  }
  updateProvidersLocked();
}

Fixed version (ground truth):
private void _loadProvidersLocked(){
  if (GpsLocationProvider.isSupported()) {
    GpsLocationProvider provider=new GpsLocationProvider(mContext,this);
    mGpsStatusProvider=provider.getGpsStatusProvider();
    LocationProviderProxy proxy=new LocationProviderProxy(LocationManager.GPS_PROVIDER,provider);
    addProvider(proxy);
    mGpsLocationProvider=proxy;
  }
  updateProvidersLocked();
}
Program: 43269
Project: 43269
Buggy source:
/** 
 * SSL certificate error callback. Handles SSL error(s) on the way up to the user. IMPORTANT: as this is called from network thread, can't call native directly
 */
public boolean handleSslErrorRequest(SslError error){
  if (DebugFlags.LOAD_LISTENER) {
    Log.v(LOGTAG,"String_Node_Str" + url() + "String_Node_Str"+ error.getPrimaryError()+ "String_Node_Str"+ error.getCertificate());
  }
  sendMessageInternal(obtainMessage(MSG_SSL_ERROR,error));
  if (!mCancelled) {
    mSslErrorRequestHandle=mRequestHandle;
  }
  return !mCancelled;
}

Fixed version (ground truth):
/** 
 * SSL certificate error callback. Handles SSL error(s) on the way up to the user. IMPORTANT: as this is called from network thread, can't call native directly
 */
public boolean handleSslErrorRequest(SslError error){
  if (DebugFlags.LOAD_LISTENER) {
    Log.v(LOGTAG,"String_Node_Str" + url() + "String_Node_Str"+ error.getPrimaryError()+ "String_Node_Str"+ error.getCertificate());
  }
  if (Network.getInstance(mContext).checkSslPrefTable(this,error)) {
    return true;
  }
  if (isSynchronous()) {
    mRequestHandle.handleSslErrorResponse(false);
    return true;
  }
  sendMessageInternal(obtainMessage(MSG_SSL_ERROR,error));
  if (!mCancelled) {
    mSslErrorRequestHandle=mRequestHandle;
  }
  return !mCancelled;
}
Program: 43270
Project: 43270
Buggy source:
/** 
 * Cancel this request and all pending requests for the WebView that had the error.
 */
public void cancel(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,0,0));
}

Fixed version (ground truth):
/** 
 * Cancel this request and all pending requests for the WebView that had the error.
 */
public void cancel(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,0,0,mLoaderQueue.poll()));
}
Program: 43271
Project: 43271
Buggy source:
/** 
 * Handles SSL error(s) on the way down from the user.
 */
synchronized void handleSslErrorResponse(boolean proceed){
  LoadListener loader=mLoaderQueue.poll();
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Assert.assertNotNull(loader);
  }
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Log.v(LOGTAG,"String_Node_Str" + "String_Node_Str" + proceed + "String_Node_Str"+ loader.url());
  }
  if (!loader.cancelled()) {
    if (proceed) {
      int primary=loader.sslError().getPrimaryError();
      String host=loader.host();
      if (DebugFlags.SSL_ERROR_HANDLER) {
        Assert.assertTrue(host != null && primary != 0);
      }
      boolean hasKey=mSslPrefTable.containsKey(host);
      if (!hasKey || primary > mSslPrefTable.getInt(host)) {
        mSslPrefTable.putInt(host,primary);
      }
    }
    loader.handleSslErrorResponse(proceed);
  }
}

Fixed version (ground truth):
/** 
 * Handles SSL error(s) on the way down from the user.
 */
synchronized void handleSslErrorResponse(LoadListener loader,SslError error,boolean proceed){
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Assert.assertNotNull(loader);
    Assert.assertNotNull(error);
  }
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Log.v(LOGTAG,"String_Node_Str" + "String_Node_Str" + proceed + "String_Node_Str"+ loader.url());
  }
  if (!loader.cancelled()) {
    if (proceed) {
      int primary=error.getPrimaryError();
      String host=loader.host();
      if (DebugFlags.SSL_ERROR_HANDLER) {
        Assert.assertTrue(host != null && primary != 0);
      }
      boolean hasKey=mSslPrefTable.containsKey(host);
      if (!hasKey || primary > mSslPrefTable.getInt(host)) {
        mSslPrefTable.putInt(host,primary);
      }
    }
    loader.handleSslErrorResponse(proceed);
  }
}
Program: 43272
Project: 43272
Buggy source:
/** 
 * Restores this handler's state from a map.
 * @return True iff succeeds.
 */
boolean restoreState(Bundle inState){
  boolean success=(inState != null);
  if (success) {
    success=inState.containsKey("String_Node_Str");
    if (success) {
      mSslPrefTable=inState.getBundle("String_Node_Str");
    }
  }
  return success;
}

Fixed version (ground truth):
/** 
 * Restores this handler's state from a map.
 * @return True iff succeeds.
 */
synchronized boolean restoreState(Bundle inState){
  boolean success=(inState != null);
  if (success) {
    success=inState.containsKey("String_Node_Str");
    if (success) {
      mSslPrefTable=inState.getBundle("String_Node_Str");
    }
  }
  return success;
}
Program: 43273
Project: 43273
Buggy source:
/** 
 * Proceed with the SSL certificate.
 */
public void proceed(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,1,0));
}

Fixed version (ground truth):
/** 
 * Proceed with the SSL certificate.
 */
public void proceed(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,1,0,mLoaderQueue.poll()));
}
Program: 43274
Project: 43274
Buggy source:
/** 
 * Saves this handler's state into a map.
 * @return True iff succeeds.
 */
boolean saveState(Bundle outState){
  boolean success=(outState != null);
  if (success) {
    outState.putBundle("String_Node_Str",mSslPrefTable);
  }
  return success;
}

Fixed version (ground truth):
/** 
 * Saves this handler's state into a map.
 * @return True iff succeeds.
 */
synchronized boolean saveState(Bundle outState){
  boolean success=(outState != null);
  if (success) {
    outState.putBundle("String_Node_Str",mSslPrefTable);
  }
  return success;
}
Program: 43275
Project: 43275
Buggy source:
/** 
 * Processes the next loader in the queue.
 * @return True iff should proceed to processing thefollowing loader in the queue
 */
private synchronized boolean processNextLoader(){
  LoadListener loader=mLoaderQueue.peek();
  if (loader != null) {
    if (loader.cancelled()) {
      return true;
    }
    SslError error=loader.sslError();
    if (DebugFlags.SSL_ERROR_HANDLER) {
      Assert.assertNotNull(error);
    }
    int primary=error.getPrimaryError();
    String host=loader.host();
    if (DebugFlags.SSL_ERROR_HANDLER) {
      Assert.assertTrue(host != null && primary != 0);
    }
    if (mSslPrefTable.containsKey(host)) {
      if (primary <= mSslPrefTable.getInt(host)) {
        handleSslErrorResponse(true);
        return true;
      }
    }
    CallbackProxy proxy=loader.getFrame().getCallbackProxy();
    proxy.onReceivedSslError(this,error);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Processes the next loader in the queue.
 * @return True iff should proceed to processing thefollowing loader in the queue
 */
private synchronized boolean processNextLoader(){
  LoadListener loader=mLoaderQueue.peek();
  if (loader != null) {
    if (loader.cancelled()) {
      mLoaderQueue.remove(loader);
      return true;
    }
    SslError error=loader.sslError();
    if (DebugFlags.SSL_ERROR_HANDLER) {
      Assert.assertNotNull(error);
    }
    if (checkSslPrefTable(loader,error)) {
      mLoaderQueue.remove(loader);
      return true;
    }
    CallbackProxy proxy=loader.getFrame().getCallbackProxy();
    proxy.onReceivedSslError(this,error);
  }
  return false;
}
Program: 43276
Project: 43276
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case HANDLE_RESPONSE:
    handleSslErrorResponse(msg.arg1 == 1);
  fastProcessQueuedSslErrors();
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case HANDLE_RESPONSE:
    LoadListener loader=(LoadListener)msg.obj;
  handleSslErrorResponse(loader,loader.sslError(),msg.arg1 == 1);
fastProcessQueuedSslErrors();
break;
}
}
Program: 43277
Project: 43277
Buggy source:
/** 
 * SSL certificate error callback. Handles SSL error(s) on the way up to the user. IMPORTANT: as this is called from network thread, can't call native directly
 */
public boolean handleSslErrorRequest(SslError error){
  if (DebugFlags.LOAD_LISTENER) {
    Log.v(LOGTAG,"String_Node_Str" + url() + "String_Node_Str"+ error.getPrimaryError()+ "String_Node_Str"+ error.getCertificate());
  }
  sendMessageInternal(obtainMessage(MSG_SSL_ERROR,error));
  if (!mCancelled) {
    mSslErrorRequestHandle=mRequestHandle;
  }
  return !mCancelled;
}

Fixed version (ground truth):
/** 
 * SSL certificate error callback. Handles SSL error(s) on the way up to the user. IMPORTANT: as this is called from network thread, can't call native directly
 */
public boolean handleSslErrorRequest(SslError error){
  if (DebugFlags.LOAD_LISTENER) {
    Log.v(LOGTAG,"String_Node_Str" + url() + "String_Node_Str"+ error.getPrimaryError()+ "String_Node_Str"+ error.getCertificate());
  }
  if (Network.getInstance(mContext).checkSslPrefTable(this,error)) {
    return true;
  }
  if (isSynchronous()) {
    mRequestHandle.handleSslErrorResponse(false);
    return true;
  }
  sendMessageInternal(obtainMessage(MSG_SSL_ERROR,error));
  if (!mCancelled) {
    mSslErrorRequestHandle=mRequestHandle;
  }
  return !mCancelled;
}
Program: 43278
Project: 43278
Buggy source:
/** 
 * Cancel this request and all pending requests for the WebView that had the error.
 */
public void cancel(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,0,0));
}

Fixed version (ground truth):
/** 
 * Cancel this request and all pending requests for the WebView that had the error.
 */
public void cancel(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,0,0,mLoaderQueue.poll()));
}
Program: 43279
Project: 43279
Buggy source:
/** 
 * Handles SSL error(s) on the way down from the user.
 */
synchronized void handleSslErrorResponse(boolean proceed){
  LoadListener loader=mLoaderQueue.poll();
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Assert.assertNotNull(loader);
  }
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Log.v(LOGTAG,"String_Node_Str" + "String_Node_Str" + proceed + "String_Node_Str"+ loader.url());
  }
  if (!loader.cancelled()) {
    if (proceed) {
      int primary=loader.sslError().getPrimaryError();
      String host=loader.host();
      if (DebugFlags.SSL_ERROR_HANDLER) {
        Assert.assertTrue(host != null && primary != 0);
      }
      boolean hasKey=mSslPrefTable.containsKey(host);
      if (!hasKey || primary > mSslPrefTable.getInt(host)) {
        mSslPrefTable.putInt(host,primary);
      }
    }
    loader.handleSslErrorResponse(proceed);
  }
}

Fixed version (ground truth):
/** 
 * Handles SSL error(s) on the way down from the user.
 */
synchronized void handleSslErrorResponse(LoadListener loader,SslError error,boolean proceed){
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Assert.assertNotNull(loader);
    Assert.assertNotNull(error);
  }
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Log.v(LOGTAG,"String_Node_Str" + "String_Node_Str" + proceed + "String_Node_Str"+ loader.url());
  }
  if (!loader.cancelled()) {
    if (proceed) {
      int primary=error.getPrimaryError();
      String host=loader.host();
      if (DebugFlags.SSL_ERROR_HANDLER) {
        Assert.assertTrue(host != null && primary != 0);
      }
      boolean hasKey=mSslPrefTable.containsKey(host);
      if (!hasKey || primary > mSslPrefTable.getInt(host)) {
        mSslPrefTable.putInt(host,primary);
      }
    }
    loader.handleSslErrorResponse(proceed);
  }
}
Program: 43280
Project: 43280
Buggy source:
/** 
 * Restores this handler's state from a map.
 * @return True iff succeeds.
 */
boolean restoreState(Bundle inState){
  boolean success=(inState != null);
  if (success) {
    success=inState.containsKey("String_Node_Str");
    if (success) {
      mSslPrefTable=inState.getBundle("String_Node_Str");
    }
  }
  return success;
}

Fixed version (ground truth):
/** 
 * Restores this handler's state from a map.
 * @return True iff succeeds.
 */
synchronized boolean restoreState(Bundle inState){
  boolean success=(inState != null);
  if (success) {
    success=inState.containsKey("String_Node_Str");
    if (success) {
      mSslPrefTable=inState.getBundle("String_Node_Str");
    }
  }
  return success;
}
Program: 43281
Project: 43281
Buggy source:
/** 
 * Proceed with the SSL certificate.
 */
public void proceed(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,1,0));
}

Fixed version (ground truth):
/** 
 * Proceed with the SSL certificate.
 */
public void proceed(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,1,0,mLoaderQueue.poll()));
}
Program: 43282
Project: 43282
Buggy source:
/** 
 * Saves this handler's state into a map.
 * @return True iff succeeds.
 */
boolean saveState(Bundle outState){
  boolean success=(outState != null);
  if (success) {
    outState.putBundle("String_Node_Str",mSslPrefTable);
  }
  return success;
}

Fixed version (ground truth):
/** 
 * Saves this handler's state into a map.
 * @return True iff succeeds.
 */
synchronized boolean saveState(Bundle outState){
  boolean success=(outState != null);
  if (success) {
    outState.putBundle("String_Node_Str",mSslPrefTable);
  }
  return success;
}
Program: 43283
Project: 43283
Buggy source:
/** 
 * Processes the next loader in the queue.
 * @return True iff should proceed to processing thefollowing loader in the queue
 */
private synchronized boolean processNextLoader(){
  LoadListener loader=mLoaderQueue.peek();
  if (loader != null) {
    if (loader.cancelled()) {
      return true;
    }
    SslError error=loader.sslError();
    if (DebugFlags.SSL_ERROR_HANDLER) {
      Assert.assertNotNull(error);
    }
    int primary=error.getPrimaryError();
    String host=loader.host();
    if (DebugFlags.SSL_ERROR_HANDLER) {
      Assert.assertTrue(host != null && primary != 0);
    }
    if (mSslPrefTable.containsKey(host)) {
      if (primary <= mSslPrefTable.getInt(host)) {
        handleSslErrorResponse(true);
        return true;
      }
    }
    CallbackProxy proxy=loader.getFrame().getCallbackProxy();
    proxy.onReceivedSslError(this,error);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Processes the next loader in the queue.
 * @return True iff should proceed to processing thefollowing loader in the queue
 */
private synchronized boolean processNextLoader(){
  LoadListener loader=mLoaderQueue.peek();
  if (loader != null) {
    if (loader.cancelled()) {
      mLoaderQueue.remove(loader);
      return true;
    }
    SslError error=loader.sslError();
    if (DebugFlags.SSL_ERROR_HANDLER) {
      Assert.assertNotNull(error);
    }
    if (checkSslPrefTable(loader,error)) {
      mLoaderQueue.remove(loader);
      return true;
    }
    CallbackProxy proxy=loader.getFrame().getCallbackProxy();
    proxy.onReceivedSslError(this,error);
  }
  return false;
}
Program: 43284
Project: 43284
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case HANDLE_RESPONSE:
    handleSslErrorResponse(msg.arg1 == 1);
  fastProcessQueuedSslErrors();
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case HANDLE_RESPONSE:
    LoadListener loader=(LoadListener)msg.obj;
  handleSslErrorResponse(loader,loader.sslError(),msg.arg1 == 1);
fastProcessQueuedSslErrors();
break;
}
}
Program: 43285
Project: 43285
Buggy source:
/** 
 * SSL certificate error callback. Handles SSL error(s) on the way up to the user. IMPORTANT: as this is called from network thread, can't call native directly
 */
public boolean handleSslErrorRequest(SslError error){
  if (DebugFlags.LOAD_LISTENER) {
    Log.v(LOGTAG,"String_Node_Str" + url() + "String_Node_Str"+ error.getPrimaryError()+ "String_Node_Str"+ error.getCertificate());
  }
  sendMessageInternal(obtainMessage(MSG_SSL_ERROR,error));
  if (!mCancelled) {
    mSslErrorRequestHandle=mRequestHandle;
  }
  return !mCancelled;
}

Fixed version (ground truth):
/** 
 * SSL certificate error callback. Handles SSL error(s) on the way up to the user. IMPORTANT: as this is called from network thread, can't call native directly
 */
public boolean handleSslErrorRequest(SslError error){
  if (DebugFlags.LOAD_LISTENER) {
    Log.v(LOGTAG,"String_Node_Str" + url() + "String_Node_Str"+ error.getPrimaryError()+ "String_Node_Str"+ error.getCertificate());
  }
  if (Network.getInstance(mContext).checkSslPrefTable(this,error)) {
    return true;
  }
  if (isSynchronous()) {
    mRequestHandle.handleSslErrorResponse(false);
    return true;
  }
  sendMessageInternal(obtainMessage(MSG_SSL_ERROR,error));
  if (!mCancelled) {
    mSslErrorRequestHandle=mRequestHandle;
  }
  return !mCancelled;
}
Program: 43286
Project: 43286
Buggy source:
/** 
 * Cancel this request and all pending requests for the WebView that had the error.
 */
public void cancel(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,0,0));
}

Fixed version (ground truth):
/** 
 * Cancel this request and all pending requests for the WebView that had the error.
 */
public void cancel(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,0,0,mLoaderQueue.poll()));
}
Program: 43287
Project: 43287
Buggy source:
/** 
 * Handles SSL error(s) on the way down from the user.
 */
synchronized void handleSslErrorResponse(boolean proceed){
  LoadListener loader=mLoaderQueue.poll();
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Assert.assertNotNull(loader);
  }
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Log.v(LOGTAG,"String_Node_Str" + "String_Node_Str" + proceed + "String_Node_Str"+ loader.url());
  }
  if (!loader.cancelled()) {
    if (proceed) {
      int primary=loader.sslError().getPrimaryError();
      String host=loader.host();
      if (DebugFlags.SSL_ERROR_HANDLER) {
        Assert.assertTrue(host != null && primary != 0);
      }
      boolean hasKey=mSslPrefTable.containsKey(host);
      if (!hasKey || primary > mSslPrefTable.getInt(host)) {
        mSslPrefTable.putInt(host,primary);
      }
    }
    loader.handleSslErrorResponse(proceed);
  }
}

Fixed version (ground truth):
/** 
 * Handles SSL error(s) on the way down from the user.
 */
synchronized void handleSslErrorResponse(LoadListener loader,SslError error,boolean proceed){
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Assert.assertNotNull(loader);
    Assert.assertNotNull(error);
  }
  if (DebugFlags.SSL_ERROR_HANDLER) {
    Log.v(LOGTAG,"String_Node_Str" + "String_Node_Str" + proceed + "String_Node_Str"+ loader.url());
  }
  if (!loader.cancelled()) {
    if (proceed) {
      int primary=error.getPrimaryError();
      String host=loader.host();
      if (DebugFlags.SSL_ERROR_HANDLER) {
        Assert.assertTrue(host != null && primary != 0);
      }
      boolean hasKey=mSslPrefTable.containsKey(host);
      if (!hasKey || primary > mSslPrefTable.getInt(host)) {
        mSslPrefTable.putInt(host,primary);
      }
    }
    loader.handleSslErrorResponse(proceed);
  }
}
Program: 43288
Project: 43288
Buggy source:
/** 
 * Restores this handler's state from a map.
 * @return True iff succeeds.
 */
boolean restoreState(Bundle inState){
  boolean success=(inState != null);
  if (success) {
    success=inState.containsKey("String_Node_Str");
    if (success) {
      mSslPrefTable=inState.getBundle("String_Node_Str");
    }
  }
  return success;
}

Fixed version (ground truth):
/** 
 * Restores this handler's state from a map.
 * @return True iff succeeds.
 */
synchronized boolean restoreState(Bundle inState){
  boolean success=(inState != null);
  if (success) {
    success=inState.containsKey("String_Node_Str");
    if (success) {
      mSslPrefTable=inState.getBundle("String_Node_Str");
    }
  }
  return success;
}
Program: 43289
Project: 43289
Buggy source:
/** 
 * Proceed with the SSL certificate.
 */
public void proceed(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,1,0));
}

Fixed version (ground truth):
/** 
 * Proceed with the SSL certificate.
 */
public void proceed(){
  sendMessage(obtainMessage(HANDLE_RESPONSE,1,0,mLoaderQueue.poll()));
}
Program: 43290
Project: 43290
Buggy source:
/** 
 * Saves this handler's state into a map.
 * @return True iff succeeds.
 */
boolean saveState(Bundle outState){
  boolean success=(outState != null);
  if (success) {
    outState.putBundle("String_Node_Str",mSslPrefTable);
  }
  return success;
}

Fixed version (ground truth):
/** 
 * Saves this handler's state into a map.
 * @return True iff succeeds.
 */
synchronized boolean saveState(Bundle outState){
  boolean success=(outState != null);
  if (success) {
    outState.putBundle("String_Node_Str",mSslPrefTable);
  }
  return success;
}
Program: 43291
Project: 43291
Buggy source:
/** 
 * Processes the next loader in the queue.
 * @return True iff should proceed to processing thefollowing loader in the queue
 */
private synchronized boolean processNextLoader(){
  LoadListener loader=mLoaderQueue.peek();
  if (loader != null) {
    if (loader.cancelled()) {
      return true;
    }
    SslError error=loader.sslError();
    if (DebugFlags.SSL_ERROR_HANDLER) {
      Assert.assertNotNull(error);
    }
    int primary=error.getPrimaryError();
    String host=loader.host();
    if (DebugFlags.SSL_ERROR_HANDLER) {
      Assert.assertTrue(host != null && primary != 0);
    }
    if (mSslPrefTable.containsKey(host)) {
      if (primary <= mSslPrefTable.getInt(host)) {
        handleSslErrorResponse(true);
        return true;
      }
    }
    CallbackProxy proxy=loader.getFrame().getCallbackProxy();
    proxy.onReceivedSslError(this,error);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Processes the next loader in the queue.
 * @return True iff should proceed to processing thefollowing loader in the queue
 */
private synchronized boolean processNextLoader(){
  LoadListener loader=mLoaderQueue.peek();
  if (loader != null) {
    if (loader.cancelled()) {
      mLoaderQueue.remove(loader);
      return true;
    }
    SslError error=loader.sslError();
    if (DebugFlags.SSL_ERROR_HANDLER) {
      Assert.assertNotNull(error);
    }
    if (checkSslPrefTable(loader,error)) {
      mLoaderQueue.remove(loader);
      return true;
    }
    CallbackProxy proxy=loader.getFrame().getCallbackProxy();
    proxy.onReceivedSslError(this,error);
  }
  return false;
}
Program: 43292
Project: 43292
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case HANDLE_RESPONSE:
    handleSslErrorResponse(msg.arg1 == 1);
  fastProcessQueuedSslErrors();
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case HANDLE_RESPONSE:
    LoadListener loader=(LoadListener)msg.obj;
  handleSslErrorResponse(loader,loader.sslError(),msg.arg1 == 1);
fastProcessQueuedSslErrors();
break;
}
}
Program: 43293
Project: 43293
Buggy source:
@Override public EGLConfig chooseConfig(EGL10 egl,EGLDisplay display,EGLConfig[] configs){
  EGLConfig closestConfig=null;
  int closestDistance=1000;
  for (  EGLConfig config : configs) {
    int r=findConfigAttrib(egl,display,config,EGL10.EGL_RED_SIZE,0);
    int g=findConfigAttrib(egl,display,config,EGL10.EGL_GREEN_SIZE,0);
    int b=findConfigAttrib(egl,display,config,EGL10.EGL_BLUE_SIZE,0);
    int a=findConfigAttrib(egl,display,config,EGL10.EGL_ALPHA_SIZE,0);
    int d=findConfigAttrib(egl,display,config,EGL10.EGL_DEPTH_SIZE,0);
    int s=findConfigAttrib(egl,display,config,EGL10.EGL_STENCIL_SIZE,0);
    int distance=Math.abs(r - mRedSize) + Math.abs(g - mGreenSize) + Math.abs(b - mBlueSize)+ Math.abs(a - mAlphaSize)+ Math.abs(d - mDepthSize)+ Math.abs(s - mStencilSize);
    if (distance < closestDistance) {
      closestDistance=distance;
      closestConfig=config;
    }
  }
  return closestConfig;
}

Fixed version (ground truth):
@Override public EGLConfig chooseConfig(EGL10 egl,EGLDisplay display,EGLConfig[] configs){
  EGLConfig closestConfig=null;
  int closestDistance=1000;
  for (  EGLConfig config : configs) {
    int d=findConfigAttrib(egl,display,config,EGL10.EGL_DEPTH_SIZE,0);
    int s=findConfigAttrib(egl,display,config,EGL10.EGL_STENCIL_SIZE,0);
    if (d >= mDepthSize && s >= mStencilSize) {
      int r=findConfigAttrib(egl,display,config,EGL10.EGL_RED_SIZE,0);
      int g=findConfigAttrib(egl,display,config,EGL10.EGL_GREEN_SIZE,0);
      int b=findConfigAttrib(egl,display,config,EGL10.EGL_BLUE_SIZE,0);
      int a=findConfigAttrib(egl,display,config,EGL10.EGL_ALPHA_SIZE,0);
      int distance=Math.abs(r - mRedSize) + Math.abs(g - mGreenSize) + Math.abs(b - mBlueSize)+ Math.abs(a - mAlphaSize);
      if (distance < closestDistance) {
        closestDistance=distance;
        closestConfig=config;
      }
    }
  }
  return closestConfig;
}
Program: 43295
Project: 43295
Buggy source:
/** 
 * This function handles the plus code conversion within NANP CDMA network If the number format is 1)+NANP or +1NANP,remove +, 2)+non-NANP Numbers,replace + with the current IDP
 */
private static String processPlusCodeWithinNanp(String networkDialStr){
  String retStr=networkDialStr;
  if (DBG)   log("String_Node_Str" + networkDialStr);
  if (networkDialStr != null & networkDialStr.charAt(0) == PLUS_SIGN_CHAR && networkDialStr.length() > 1) {
    String newStr=networkDialStr.substring(1);
    if (isNanp(newStr) || isOneNanp(newStr)) {
      retStr=newStr;
    }
 else {
      String idpStr=getDefaultIdp();
      retStr=networkDialStr.replaceFirst("String_Node_Str",idpStr);
    }
  }
  if (DBG)   log("String_Node_Str" + retStr);
  return retStr;
}

Fixed version (ground truth):
/** 
 * This function handles the plus code conversion within NANP CDMA network If the number format is 1)+1NANP,remove +, 2)other than +1NANP, any + numbers,replace + with the current IDP
 */
private static String processPlusCodeWithinNanp(String networkDialStr){
  String retStr=networkDialStr;
  if (DBG)   log("String_Node_Str" + networkDialStr);
  if (networkDialStr != null & networkDialStr.charAt(0) == PLUS_SIGN_CHAR && networkDialStr.length() > 1) {
    String newStr=networkDialStr.substring(1);
    if (isOneNanp(newStr)) {
      retStr=newStr;
    }
 else {
      String idpStr=getDefaultIdp();
      retStr=networkDialStr.replaceFirst("String_Node_Str",idpStr);
    }
  }
  if (DBG)   log("String_Node_Str" + retStr);
  return retStr;
}
Program: 43296
Project: 43296
Buggy source:
/** 
 * Returns the phone number formatting type for the given locale.
 * @param locale The locale of interest, usually {@link Locale#getDefault()}
 * @return the formatting type for the given locale, or FORMAT_UNKNOWN if the formattingrules are not known for the given locale
 */
public static int getFormatTypeForLocale(Locale locale){
  String country=locale.getCountry();
  int length=NANP_COUNTRIES.length;
  for (int i=0; i < length; i++) {
    if (NANP_COUNTRIES[i].equals(country)) {
      return FORMAT_NANP;
    }
  }
  if (locale.equals(Locale.JAPAN)) {
    return FORMAT_JAPAN;
  }
  return FORMAT_UNKNOWN;
}

Fixed version (ground truth):
/** 
 * Returns the phone number formatting type for the given locale.
 * @param locale The locale of interest, usually {@link Locale#getDefault()}
 * @return the formatting type for the given locale, or FORMAT_UNKNOWN if the formattingrules are not known for the given locale
 */
public static int getFormatTypeForLocale(Locale locale){
  String country=locale.getCountry();
  return getFormatTypeFromCountryCode(country);
}
Program: 43298
Project: 43298
Buggy source:
@SmallTest public void testCheckAndProcessPlusCodeByNumberFormat(){
  assertEquals("String_Node_Str",PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("String_Node_Str",PhoneNumberUtils.FORMAT_JAPAN));
  assertEquals("String_Node_Str",PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("String_Node_Str",PhoneNumberUtils.FORMAT_JAPAN));
  assertEquals("String_Node_Str",PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("String_Node_Str",PhoneNumberUtils.FORMAT_UNKNOWN));
  assertEquals("String_Node_Str",PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("String_Node_Str",PhoneNumberUtils.FORMAT_UNKNOWN));
}

Fixed version (ground truth):
@SmallTest public void testCheckAndProcessPlusCodeByNumberFormat(){
  assertEquals("String_Node_Str",PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("String_Node_Str",PhoneNumberUtils.FORMAT_NANP,PhoneNumberUtils.FORMAT_NANP));
  assertEquals("String_Node_Str",PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("String_Node_Str",PhoneNumberUtils.FORMAT_NANP,PhoneNumberUtils.FORMAT_JAPAN));
  assertEquals("String_Node_Str",PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("String_Node_Str",PhoneNumberUtils.FORMAT_NANP,PhoneNumberUtils.FORMAT_UNKNOWN));
  assertEquals("String_Node_Str",PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("String_Node_Str",PhoneNumberUtils.FORMAT_JAPAN,PhoneNumberUtils.FORMAT_JAPAN));
  assertEquals("String_Node_Str",PhoneNumberUtils.cdmaCheckAndProcessPlusCodeByNumberFormat("String_Node_Str",PhoneNumberUtils.FORMAT_UNKNOWN,PhoneNumberUtils.FORMAT_UNKNOWN));
}
Program: 43299
Project: 43299
Buggy source:
/** 
 * Ensure that a network route exists to deliver traffic to the specified host via the mobile data network.
 * @param hostAddress the IP address of the host to which the route is desired,in network byte order.
 * @return {@code true} on success, {@code false} on failure
 */
@Override public boolean requestRouteToHost(int hostAddress){
  if (mInterfaceName != null && hostAddress != -1) {
    if (DBG) {
      Log.d(TAG,"String_Node_Str" + Integer.toHexString(hostAddress));
    }
    return NetworkUtils.addHostRoute(mInterfaceName,hostAddress) == 0;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Ensure that a network route exists to deliver traffic to the specified host via the mobile data network.
 * @param hostAddress the IP address of the host to which the route is desired,in network byte order.
 * @return {@code true} on success, {@code false} on failure
 */
@Override public boolean requestRouteToHost(int hostAddress){
  if (DBG) {
    Log.d(TAG,"String_Node_Str" + Integer.toHexString(hostAddress) + "String_Node_Str"+ mApnType+ "String_Node_Str"+ mInterfaceName+ "String_Node_Str");
  }
  if (mInterfaceName != null && hostAddress != -1) {
    return NetworkUtils.addHostRoute(mInterfaceName,hostAddress) == 0;
  }
 else {
    return false;
  }
}
Program: 43301
Project: 43301
Buggy source:
/** 
 * Re-enable mobile data connectivity after a   {@link #teardown()}.
 */
public boolean reconnect(){
  setTeardownRequested(false);
switch (setEnableApn(mApnType,true)) {
case Phone.APN_ALREADY_ACTIVE:
    mEnabled=true;
  Intent intent=new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
intent.putExtra(Phone.STATE_KEY,Phone.DataState.CONNECTED.toString());
intent.putExtra(Phone.STATE_CHANGE_REASON_KEY,Phone.REASON_APN_CHANGED);
intent.putExtra(Phone.DATA_APN_TYPES_KEY,mApnType);
intent.putExtra(Phone.DATA_IFACE_NAME_KEY,mInterfaceName);
intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY,false);
if (mStateReceiver != null) mStateReceiver.onReceive(mContext,intent);
break;
case Phone.APN_REQUEST_STARTED:
mEnabled=true;
break;
case Phone.APN_REQUEST_FAILED:
if (mPhoneService == null && mApnType == Phone.APN_TYPE_DEFAULT) {
return false;
}
case Phone.APN_TYPE_NOT_AVAILABLE:
mEnabled=false;
break;
default :
Log.e(TAG,"String_Node_Str");
mEnabled=false;
break;
}
return mEnabled;
}

Fixed version (ground truth):
/** 
 * Re-enable mobile data connectivity after a   {@link #teardown()}.
 */
public boolean reconnect(){
  setTeardownRequested(false);
switch (setEnableApn(mApnType,true)) {
case Phone.APN_ALREADY_ACTIVE:
    mEnabled=true;
  mMobileDataState=Phone.DataState.CONNECTING;
Intent intent=new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
intent.putExtra(Phone.STATE_KEY,Phone.DataState.CONNECTED.toString());
intent.putExtra(Phone.STATE_CHANGE_REASON_KEY,Phone.REASON_APN_CHANGED);
intent.putExtra(Phone.DATA_APN_TYPES_KEY,mApnType);
intent.putExtra(Phone.DATA_IFACE_NAME_KEY,mInterfaceName);
intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY,false);
if (mStateReceiver != null) mStateReceiver.onReceive(mContext,intent);
break;
case Phone.APN_REQUEST_STARTED:
mEnabled=true;
break;
case Phone.APN_REQUEST_FAILED:
if (mPhoneService == null && mApnType == Phone.APN_TYPE_DEFAULT) {
return false;
}
case Phone.APN_TYPE_NOT_AVAILABLE:
mEnabled=false;
break;
default :
Log.e(TAG,"String_Node_Str");
mEnabled=false;
break;
}
return mEnabled;
}
Program: 43302
Project: 43302
Buggy source:
private int getNumConnectedNetworks(){
  int numConnectedNets=0;
  for (  NetworkStateTracker nt : mNetTrackers) {
    if (nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) {
      ++numConnectedNets;
    }
  }
  return numConnectedNets;
}

Fixed version (ground truth):
private int getNumConnectedNetworks(){
  int numConnectedNets=0;
  for (  NetworkStateTracker nt : mNetTrackers) {
    if (nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) {
      ++numConnectedNets;
    }
  }
  if (DBG)   Log.d(TAG,"String_Node_Str" + numConnectedNets);
  return numConnectedNets;
}
Program: 43305
Project: 43305
Buggy source:
protected synchronized void setEnabled(int id,boolean enable){
  if (DBG)   Log.d(LOG_TAG,"String_Node_Str" + id + "String_Node_Str"+ enable+ ')');
  if (dataEnabled[id] != enable) {
    dataEnabled[id]=enable;
    if (enable) {
      enabledCount++;
    }
 else {
      enabledCount--;
    }
    if (enabledCount == 0) {
      setPrivateDataEnabled(false);
    }
 else     if (enabledCount == 1) {
      setPrivateDataEnabled(true);
    }
  }
}

Fixed version (ground truth):
protected synchronized void setEnabled(int id,boolean enable){
  if (DBG)   Log.d(LOG_TAG,"String_Node_Str" + id + "String_Node_Str"+ enable+ ')');
  if (dataEnabled[id] != enable) {
    dataEnabled[id]=enable;
    if (enable) {
      enabledCount++;
      if (enabledCount == 1) {
        setPrivateDataEnabled(true);
      }
    }
 else {
      enabledCount--;
      if (enabledCount == 0) {
        setPrivateDataEnabled(false);
      }
    }
  }
}
Program: 43307
Project: 43307
Buggy source:
@Override public boolean onTouchEvent(MotionEvent me){
  int pointerCount=me.getPointerCount();
  boolean result=false;
  if (pointerCount != mOldPointerCount) {
    long now=me.getEventTime();
    if (pointerCount == 1) {
      MotionEvent down=MotionEvent.obtain(now,now,MotionEvent.ACTION_DOWN,me.getX(),me.getY(),me.getMetaState());
      result=onModifiedTouchEvent(down);
      down.recycle();
    }
 else {
      MotionEvent up=MotionEvent.obtain(now,now,MotionEvent.ACTION_UP,mOldPointerX,mOldPointerY,me.getMetaState());
      result=onModifiedTouchEvent(up);
      up.recycle();
    }
  }
 else {
    if (pointerCount == 1) {
      mOldPointerX=me.getX();
      mOldPointerY=me.getY();
      result=onModifiedTouchEvent(me);
    }
 else {
      result=true;
    }
  }
  mOldPointerCount=pointerCount;
  return result;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent me){
  int pointerCount=me.getPointerCount();
  boolean result=false;
  if (pointerCount != mOldPointerCount) {
    long now=me.getEventTime();
    if (pointerCount == 1) {
      MotionEvent down=MotionEvent.obtain(now,now,MotionEvent.ACTION_DOWN,me.getX(),me.getY(),me.getMetaState());
      result=onModifiedTouchEvent(down);
      down.recycle();
      if (me.getAction() == MotionEvent.ACTION_UP) {
        result=onModifiedTouchEvent(me);
      }
    }
 else {
      MotionEvent up=MotionEvent.obtain(now,now,MotionEvent.ACTION_UP,mOldPointerX,mOldPointerY,me.getMetaState());
      result=onModifiedTouchEvent(up);
      up.recycle();
    }
  }
 else {
    if (pointerCount == 1) {
      mOldPointerX=me.getX();
      mOldPointerY=me.getY();
      result=onModifiedTouchEvent(me);
    }
 else {
      result=true;
    }
  }
  mOldPointerCount=pointerCount;
  return result;
}
Program: 43309
Project: 43309
Buggy source:
public void runTest(TestResult testResult){
  mTestResult=testResult;
  for (  TestListener testListener : mTestListeners) {
    mTestResult.addListener(testListener);
  }
  Context testContext=mInstrumentation.getContext();
  for (  TestCase testCase : mTestCases) {
    setContextIfAndroidTestCase(testCase,mContext,testContext);
    setInstrumentationIfInstrumentationTestCase(testCase,mInstrumentation);
    testCase.run(mTestResult);
  }
}

Fixed version (ground truth):
public void runTest(TestResult testResult){
  mTestResult=testResult;
  for (  TestListener testListener : mTestListeners) {
    mTestResult.addListener(testListener);
  }
  Context testContext=mInstrumentation == null ? mContext : mInstrumentation.getContext();
  for (  TestCase testCase : mTestCases) {
    setContextIfAndroidTestCase(testCase,mContext,testContext);
    setInstrumentationIfInstrumentationTestCase(testCase,mInstrumentation);
    testCase.run(mTestResult);
  }
}
Program: 43311
Project: 43311
Buggy source:
public void onSensorChanged(SensorEvent event){
  long milliseconds=event.timestamp / 1000000;
  if (event.values[0] == 0.0) {
    goToSleep(milliseconds);
  }
 else {
    userActivity(milliseconds,false);
  }
}

Fixed version (ground truth):
public void onSensorChanged(SensorEvent event){
  long milliseconds=event.timestamp / 1000000;
  if (event.values[0] == 0.0) {
    goToSleep(milliseconds);
  }
 else {
synchronized (mLocks) {
      boolean savedActivityAllowed=mUserActivityAllowed;
      mUserActivityAllowed=true;
      userActivity(milliseconds,false);
      mUserActivityAllowed=savedActivityAllowed;
    }
  }
}
Program: 43312
Project: 43312
Buggy source:
/** 
 * This is the internal entry point for handling Activity.finish().
 * @param token The Binder token referencing the Activity we want to finish.
 * @param resultCode Result code, if any, from this Activity.
 * @param resultData Result data (Intent), if any, from this Activity.
 * @result Returns true if the activity successfully finished, or false if it is still running.
 */
public final boolean finishActivity(IBinder token,int resultCode,Intent resultData){
  if (resultData != null && resultData.hasFileDescriptors() == true) {
    throw new IllegalArgumentException("String_Node_Str");
  }
synchronized (this) {
    if (mController != null) {
      HistoryRecord next=topRunningActivityLocked(token,0);
      if (next != null) {
        boolean resumeOK=true;
        try {
          resumeOK=mController.activityResuming(next.packageName);
        }
 catch (        RemoteException e) {
          mController=null;
        }
        if (!resumeOK) {
          return false;
        }
      }
    }
    final long origId=Binder.clearCallingIdentity();
    boolean res=requestFinishActivityLocked(token,resultCode,resultData,"String_Node_Str");
    Binder.restoreCallingIdentity(origId);
    return res;
  }
}

Fixed version (ground truth):
/** 
 * This is the internal entry point for handling Activity.finish().
 * @param token The Binder token referencing the Activity we want to finish.
 * @param resultCode Result code, if any, from this Activity.
 * @param resultData Result data (Intent), if any, from this Activity.
 * @return Returns true if the activity successfully finished, or false if it is still running.
 */
public final boolean finishActivity(IBinder token,int resultCode,Intent resultData){
  if (resultData != null && resultData.hasFileDescriptors() == true) {
    throw new IllegalArgumentException("String_Node_Str");
  }
synchronized (this) {
    if (mController != null) {
      HistoryRecord next=topRunningActivityLocked(token,0);
      if (next != null) {
        boolean resumeOK=true;
        try {
          resumeOK=mController.activityResuming(next.packageName);
        }
 catch (        RemoteException e) {
          mController=null;
        }
        if (!resumeOK) {
          return false;
        }
      }
    }
    final long origId=Binder.clearCallingIdentity();
    boolean res=requestFinishActivityLocked(token,resultCode,resultData,"String_Node_Str");
    Binder.restoreCallingIdentity(origId);
    return res;
  }
}