Program: 178343
Project: 178343
Buggy source:
/** 
 * write a location message to the file
 * @param context a context object used to get a content resolver object
 * @param recordId the unique record identifier for the location record
 * @throws IllegalArgumentException if the context parameter is null
 * @throws IllegalArgumentException if a record cannot be found
 */
public static void writeLocation(Context context,String recordId){
  if (context == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String mOutputPath=Environment.getExternalStorageDirectory().getPath();
  mOutputPath+=context.getString(R.string.system_path_binary_data);
  if (testPath(mOutputPath) == false) {
    Log.e(TAG,"String_Node_Str");
    return;
  }
  ContentResolver mContentResolver=context.getContentResolver();
  Uri mContentUri=Uri.parse(MapItemsContract.Locations.CONTENT_URI.toString() + "String_Node_Str" + recordId);
  Cursor mCursor=mContentResolver.query(mContentUri,null,null,null,null);
  if (mCursor.getCount() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  mCursor.moveToFirst();
  org.servalproject.maps.protobuf.LocationMessage.Message.Builder mMessageBuilder=LocationMessage.Message.newBuilder();
  mMessageBuilder.setPhoneNumber(mCursor.getString(mCursor.getColumnIndex(MapItemsContract.Locations.Table.PHONE_NUMBER)));
  mMessageBuilder.setSubsciberId(mCursor.getString(mCursor.getColumnIndex(MapItemsContract.Locations.Table.SUBSCRIBER_ID)));
  mMessageBuilder.setLatitude(mCursor.getDouble(mCursor.getColumnIndex(MapItemsContract.Locations.Table.LATITUDE)));
  mMessageBuilder.setLatitude(mCursor.getDouble(mCursor.getColumnIndex(MapItemsContract.Locations.Table.LONGITUDE)));
  mMessageBuilder.setTimestamp(mCursor.getLong(mCursor.getColumnIndex(MapItemsContract.Locations.Table.TIMESTAMP)));
  mMessageBuilder.setTimeZone(mCursor.getString(mCursor.getColumnIndex(MapItemsContract.Locations.Table.TIMEZONE)));
  String mFileName=mCursor.getString(mCursor.getColumnIndex(MapItemsContract.Locations.Table.PHONE_NUMBER));
  mFileName=mFileName.replace("String_Node_Str","String_Node_Str");
  mFileName=mFileName.replace("String_Node_Str","String_Node_Str");
  mFileName=mFileName + TimeUtils.getTodayAsString() + "String_Node_Str";
  mCursor.close();
  try {
    FileOutputStream mOutput=new FileOutputStream(mOutputPath + mFileName,true);
    mMessageBuilder.build().writeDelimitedTo(mOutput);
    mOutput.close();
  }
 catch (  FileNotFoundException e) {
    Log.e(TAG,"String_Node_Str",e);
    return;
  }
catch (  IOException e) {
    Log.e(TAG,"String_Node_Str",e);
    return;
  }
}

Fixed version (ground truth):
/** 
 * write a location message to the file
 * @param context a context object used to get a content resolver object
 * @param recordId the unique record identifier for the location record
 * @throws IllegalArgumentException if the context parameter is null
 * @throws IllegalArgumentException if a record cannot be found
 */
public static void writeLocation(Context context,String recordId){
  if (context == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String mOutputPath=Environment.getExternalStorageDirectory().getPath();
  mOutputPath+=context.getString(R.string.system_path_binary_data);
  if (testPath(mOutputPath) == false) {
    Log.e(TAG,"String_Node_Str");
    return;
  }
  ContentResolver mContentResolver=context.getContentResolver();
  Uri mContentUri=Uri.parse(MapItemsContract.Locations.CONTENT_URI.toString() + "String_Node_Str" + recordId);
  Cursor mCursor=mContentResolver.query(mContentUri,null,null,null,null);
  if (mCursor.getCount() == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  mCursor.moveToFirst();
  org.servalproject.maps.protobuf.LocationMessage.Message.Builder mMessageBuilder=LocationMessage.Message.newBuilder();
  mMessageBuilder.setPhoneNumber(mCursor.getString(mCursor.getColumnIndex(MapItemsContract.Locations.Table.PHONE_NUMBER)));
  mMessageBuilder.setSubsciberId(mCursor.getString(mCursor.getColumnIndex(MapItemsContract.Locations.Table.SUBSCRIBER_ID)));
  mMessageBuilder.setLatitude(mCursor.getDouble(mCursor.getColumnIndex(MapItemsContract.Locations.Table.LATITUDE)));
  mMessageBuilder.setLatitude(mCursor.getDouble(mCursor.getColumnIndex(MapItemsContract.Locations.Table.LONGITUDE)));
  mMessageBuilder.setTimestamp(mCursor.getLong(mCursor.getColumnIndex(MapItemsContract.Locations.Table.TIMESTAMP)));
  mMessageBuilder.setTimeZone(mCursor.getString(mCursor.getColumnIndex(MapItemsContract.Locations.Table.TIMEZONE)));
  String mFileName=mCursor.getString(mCursor.getColumnIndex(MapItemsContract.Locations.Table.PHONE_NUMBER));
  mFileName=mFileName.replace("String_Node_Str","String_Node_Str");
  mFileName=mFileName.replace("String_Node_Str","String_Node_Str");
  mFileName=mFileName + "String_Node_Str" + TimeUtils.getTodayAsString()+ "String_Node_Str";
  mCursor.close();
  try {
    FileOutputStream mOutput=new FileOutputStream(mOutputPath + mFileName,true);
    mMessageBuilder.build().writeDelimitedTo(mOutput);
    mOutput.close();
  }
 catch (  FileNotFoundException e) {
    Log.e(TAG,"String_Node_Str",e);
    return;
  }
catch (  IOException e) {
    Log.e(TAG,"String_Node_Str",e);
    return;
  }
}