Program: 84963
Project: 84963
Buggy source:
private int receiveFile(BluetoothOppReceiveFileInfo fileInfo,Operation op){
  int status=-1;
  BufferedOutputStream bos=null;
  InputStream is=null;
  boolean error=false;
  try {
    is=op.openInputStream();
  }
 catch (  IOException e1) {
    Log.e(TAG,"String_Node_Str");
    status=BluetoothShare.STATUS_OBEX_DATA_ERROR;
    error=true;
  }
  Uri contentUri=Uri.parse(BluetoothShare.CONTENT_URI + "String_Node_Str" + mInfo.mId);
  if (!error) {
    ContentValues updateValues=new ContentValues();
    updateValues.put(BluetoothShare._DATA,fileInfo.mFileName);
    mContext.getContentResolver().update(contentUri,updateValues,null,null);
  }
  int position=0;
  if (!error) {
    File f=new File(fileInfo.mFileName);
    try {
      bos=new BufferedOutputStream(new FileOutputStream(f),0x10000);
    }
 catch (    FileNotFoundException e1) {
      Log.e(TAG,"String_Node_Str" + f.toString());
      status=BluetoothShare.STATUS_FILE_ERROR;
      error=true;
    }
  }
  if (!error) {
    int outputBufferSize=op.getMaxPacketSize();
    byte[] b=new byte[outputBufferSize];
    int readLength=0;
    long timestamp;
    try {
      while ((!mInterrupted) && (position != fileInfo.mLength)) {
        if (Constants.LOGVV) {
          timestamp=System.currentTimeMillis();
        }
        readLength=is.read(b);
        if (readLength == -1) {
          if (Constants.LOGV) {
            Log.v(TAG,"String_Node_Str" + position);
          }
          break;
        }
        bos.write(b,0,readLength);
        position+=readLength;
        if (Constants.USE_EMULATOR_DEBUG) {
synchronized (this) {
            try {
              wait(300);
            }
 catch (            InterruptedException e) {
              status=BluetoothShare.STATUS_CANCELED;
              mInterrupted=true;
              if (Constants.LOGVV) {
                Log.v(TAG,"String_Node_Str" + fileInfo.mFileName + "String_Node_Str"+ position+ "String_Node_Str"+ position);
              }
              Constants.updateShareStatus(mContext,mInfo.mId,status);
            }
          }
        }
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str" + position + "String_Node_Str"+ readLength+ "String_Node_Str"+ (System.currentTimeMillis() - timestamp)+ "String_Node_Str");
        }
        ContentValues updateValues=new ContentValues();
        updateValues.put(BluetoothShare.CURRENT_BYTES,position);
        mContext.getContentResolver().update(contentUri,updateValues,null,null);
      }
    }
 catch (    IOException e1) {
      Log.e(TAG,"String_Node_Str");
      status=BluetoothShare.STATUS_OBEX_DATA_ERROR;
      error=true;
    }
  }
  if (mInterrupted) {
    if (Constants.LOGV) {
      Log.v(TAG,"String_Node_Str");
    }
    status=BluetoothShare.STATUS_CANCELED;
  }
 else {
    if (position == fileInfo.mLength) {
      if (Constants.LOGV) {
        Log.v(TAG,"String_Node_Str" + fileInfo.mFileName);
      }
      status=BluetoothShare.STATUS_SUCCESS;
    }
 else {
      if (Constants.LOGV) {
        Log.v(TAG,"String_Node_Str" + position + "String_Node_Str"+ fileInfo.mLength);
      }
      if (status == -1) {
        status=BluetoothShare.STATUS_UNKNOWN_ERROR;
      }
    }
  }
  Constants.updateShareStatus(mContext,mInfo.mId,status);
  if (bos != null) {
    try {
      bos.close();
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str");
    }
  }
  return status;
}

Fixed version (ground truth):
private int receiveFile(BluetoothOppReceiveFileInfo fileInfo,Operation op){
  int status=-1;
  BufferedOutputStream bos=null;
  InputStream is=null;
  boolean error=false;
  try {
    is=op.openInputStream();
  }
 catch (  IOException e1) {
    Log.e(TAG,"String_Node_Str");
    status=BluetoothShare.STATUS_OBEX_DATA_ERROR;
    error=true;
  }
  Uri contentUri=Uri.parse(BluetoothShare.CONTENT_URI + "String_Node_Str" + mInfo.mId);
  if (!error) {
    ContentValues updateValues=new ContentValues();
    updateValues.put(BluetoothShare._DATA,fileInfo.mFileName);
    mContext.getContentResolver().update(contentUri,updateValues,null,null);
  }
  int position=0;
  if (!error) {
    File f=new File(fileInfo.mFileName);
    try {
      bos=new BufferedOutputStream(new FileOutputStream(f),0x10000);
    }
 catch (    FileNotFoundException e1) {
      Log.e(TAG,"String_Node_Str" + f.toString());
      status=BluetoothShare.STATUS_FILE_ERROR;
      error=true;
    }
  }
  if (!error) {
    int outputBufferSize=op.getMaxPacketSize();
    byte[] b=new byte[outputBufferSize];
    int readLength=0;
    long timestamp=0;
    try {
      while ((!mInterrupted) && (position != fileInfo.mLength)) {
        if (Constants.LOGVV) {
          timestamp=System.currentTimeMillis();
        }
        readLength=is.read(b);
        if (readLength == -1) {
          if (Constants.LOGV) {
            Log.v(TAG,"String_Node_Str" + position);
          }
          break;
        }
        bos.write(b,0,readLength);
        position+=readLength;
        if (Constants.USE_EMULATOR_DEBUG) {
synchronized (this) {
            try {
              wait(300);
            }
 catch (            InterruptedException e) {
              status=BluetoothShare.STATUS_CANCELED;
              mInterrupted=true;
              if (Constants.LOGVV) {
                Log.v(TAG,"String_Node_Str" + fileInfo.mFileName + "String_Node_Str"+ position+ "String_Node_Str"+ position);
              }
              Constants.updateShareStatus(mContext,mInfo.mId,status);
            }
          }
        }
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str" + position + "String_Node_Str"+ readLength+ "String_Node_Str"+ (System.currentTimeMillis() - timestamp)+ "String_Node_Str");
        }
        ContentValues updateValues=new ContentValues();
        updateValues.put(BluetoothShare.CURRENT_BYTES,position);
        mContext.getContentResolver().update(contentUri,updateValues,null,null);
      }
    }
 catch (    IOException e1) {
      Log.e(TAG,"String_Node_Str");
      status=BluetoothShare.STATUS_OBEX_DATA_ERROR;
      error=true;
    }
  }
  if (mInterrupted) {
    if (Constants.LOGV) {
      Log.v(TAG,"String_Node_Str");
    }
    status=BluetoothShare.STATUS_CANCELED;
  }
 else {
    if (position == fileInfo.mLength) {
      if (Constants.LOGV) {
        Log.v(TAG,"String_Node_Str" + fileInfo.mFileName);
      }
      status=BluetoothShare.STATUS_SUCCESS;
    }
 else {
      if (Constants.LOGV) {
        Log.v(TAG,"String_Node_Str" + position + "String_Node_Str"+ fileInfo.mLength);
      }
      if (status == -1) {
        status=BluetoothShare.STATUS_UNKNOWN_ERROR;
      }
    }
  }
  if (bos != null) {
    try {
      bos.close();
    }
 catch (    IOException e) {
      Log.e(TAG,"String_Node_Str");
    }
  }
  return status;
}