[Demonstration 1]

[Buggy Method]
public NewsItem queryNews(final String id) {
    if (isNetworkAvailable(mContext)) {
        Thread t = new Thread() {

            @Override
            public void run() {
                try {
                    item = PagePlus.getNewsItem(id);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
        t.start();
        try {
            t.join();
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            writeJsonStream(mContext.openFileOutput("history" + item.getId(), Context.MODE_PRIVATE), item);
        } catch (Exception ee) {
            ee.printStackTrace();
        }
    } else {
        try {
            item = readJsonStreamDetail(mContext.openFileInput(id));
        } catch (Exception ee) {
            ee.printStackTrace();
        }
    }
    return item;
}

[Buggy Hunk]
item = readJsonStreamDetail(mContext.openFileInput(id));

[Patch]
item = readJsonStreamDetail(mContext.openFileInput("history" + id));

[Demonstration 2]

[Buggy Method]
public boolean hasBeenDelivered(Calendar currentDate) {
    if (MyCalendarUtils.getDiff(currentDate, deliveryDate) > 0) {
        return true;
    }
    return false;
}

[Buggy Hunk]
if ( MyCalendarUtils.getDiff(currentDate, deliveryDate) > 0 ) {

[Patch]
if ( MyCalendarUtils.getDiff(currentDate, deliveryDate) >= 0 ) {

[Demonstration 3]

[Buggy Method]
@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    //robustness code
    if (mCallback == null || (mCameraCaptureURI == null && requestCode == REQUEST_LAUNCH_IMAGE_CAPTURE) || (requestCode != REQUEST_LAUNCH_IMAGE_CAPTURE && requestCode != REQUEST_LAUNCH_IMAGE_LIBRARY && requestCode != REQUEST_LAUNCH_VIDEO_LIBRARY && requestCode != REQUEST_LAUNCH_VIDEO_CAPTURE)) {
        return;
    }
    response = Arguments.createMap();
    // user cancel
    if (resultCode != Activity.RESULT_OK) {
        response.putBoolean("didCancel", true);
        mCallback.invoke(response);
        return;
    }
    Uri uri;
    switch(requestCode) {
        case REQUEST_LAUNCH_IMAGE_CAPTURE:
            uri = mCameraCaptureURI;
            break;
        case REQUEST_LAUNCH_IMAGE_LIBRARY:
            if (mCropImagedUri != null) {
                uri = mCropImagedUri;
                // we check if we get the uri in response if we get it the crop failed so mCropImagedUri point to
                // an empty file
                Uri uriTmp = data.getData();
                if (uriTmp != null)
                    uri = uriTmp;
            } else {
                uri = data.getData();
            }
            break;
        case REQUEST_LAUNCH_VIDEO_LIBRARY:
            response.putString("uri", data.getData().toString());
            response.putString("path", getRealPathFromURI(data.getData()));
            mCallback.invoke(response);
            return;
        case REQUEST_LAUNCH_VIDEO_CAPTURE:
            response.putString("uri", data.getData().toString());
            response.putString("path", getRealPathFromURI(data.getData()));
            mCallback.invoke(response);
            return;
        default:
            uri = null;
    }
    String realPath = getRealPathFromURI(uri);
    boolean isUrl = false;
    if (realPath != null) {
        try {
            URL url = new URL(realPath);
            isUrl = true;
        } catch (MalformedURLException e) {
            // not a url
        }
    }
    // image isn't in memory cache
    if (realPath == null || isUrl) {
        try {
            File file = createFileFromURI(uri);
            realPath = file.getAbsolutePath();
            uri = Uri.fromFile(file);
        } catch (Exception e) {
            // image not in cache
            response.putString("error", "Could not read photo");
            response.putString("uri", uri.toString());
            mCallback.invoke(response);
            return;
        }
    }
    int CurrentAngle = 0;
    try {
        ExifInterface exif = new ExifInterface(realPath);
        // extract lat, long, and timestamp and add to the response
        float[] latlng = new float[2];
        exif.getLatLong(latlng);
        float latitude = latlng[0];
        float longitude = latlng[1];
        if (latitude != 0f || longitude != 0f) {
            response.putDouble("latitude", latitude);
            response.putDouble("longitude", longitude);
        }
        String timestamp = exif.getAttribute(ExifInterface.TAG_DATETIME);
        SimpleDateFormat exifDatetimeFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
        DateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        isoFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        try {
            String isoFormatString = isoFormat.format(exifDatetimeFormat.parse(timestamp)) + "Z";
            response.putString("timestamp", isoFormatString);
        } catch (ParseException e) {
        }
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        boolean isVertical = true;
        switch(orientation) {
            case ExifInterface.ORIENTATION_ROTATE_270:
                isVertical = false;
                CurrentAngle = 270;
                break;
            case ExifInterface.ORIENTATION_ROTATE_90:
                isVertical = false;
                CurrentAngle = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                CurrentAngle = 180;
                break;
        }
        response.putBoolean("isVertical", isVertical);
    } catch (IOException e) {
        e.printStackTrace();
        response.putString("error", e.getMessage());
        mCallback.invoke(response);
        return;
    }
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    Bitmap photo = BitmapFactory.decodeFile(realPath, options);
    int initialWidth = options.outWidth;
    int initialHeight = options.outHeight;
    // don't create a new file if contraint are respected
    if (((initialWidth < maxWidth && maxWidth > 0) || maxWidth == 0) && ((initialHeight < maxHeight && maxHeight > 0) || maxHeight == 0) && quality == 100 && (!forceAngle || (forceAngle && CurrentAngle == angle))) {
        response.putInt("width", initialWidth);
        response.putInt("height", initialHeight);
    } else {
        File resized = getResizedImage(realPath, initialWidth, initialHeight);
        if (resized == null) {
            response.putString("error", "Can't resize the image");
        } else {
            realPath = resized.getAbsolutePath();
            uri = Uri.fromFile(resized);
            photo = BitmapFactory.decodeFile(realPath, options);
            response.putInt("width", options.outWidth);
            response.putInt("height", options.outHeight);
        }
    }
    response.putString("uri", uri.toString());
    response.putString("path", realPath);
    if (!noData) {
        response.putString("data", getBase64StringFromFile(realPath));
    }
    putExtraFileInfo(realPath, response);
    mCallback.invoke(response);
}

[Buggy Hunk]
} catch (ParseException e) {}

[Patch]
} catch (Exception e) {}