[Demonstration 1]

[Buggy Method]
private BusinessAccount createBusinessAccountFromAccount(final Account account) {
    final List<String> tags = new ArrayList<String>();
    for (final Tag tag : account.getTagList()) {
        tags.add(tag.getTagDefinitionName());
    }
    final BusinessAccount bac = new BusinessAccount(account.getExternalKey(), // TODO We need an API for the account balance
    null, tags, // These fields will be updated below
    null, null, null, null, null, null);
    updateBusinessAccountFromAccount(account, bac);
    return bac;
}

[Buggy Hunk]
null, // TODO We need an API for the account balance

[Patch]
invoiceUserApi.getAccountBalance(account.getId()),

[Demonstration 2]

[Buggy Method]
private void fetchMessage() throws IOException {
    int fetchMessageNumber = (int) (inputSplit.getEndMessageOffset() - nextMessageOffset);
    if (fetchMessageNumber > TalosClientConfigKeys.GALAXY_TALOS_CONSUMER_MAX_FETCH_RECORDS_DEFAULT) {
        fetchMessageNumber = TalosClientConfigKeys.GALAXY_TALOS_CONSUMER_MAX_FETCH_RECORDS_DEFAULT;
    }
    int retryTimes = 0;
    TException exception = null;
    while (retryTimes < configuration.getMaxRetrys()) {
        try {
            messageAndOffsetList.addAll(simpleConsumer.fetchMessage(nextMessageOffset, fetchMessageNumber));
            if (messageAndOffsetList.size() == 0) {
                retryTimes = 0;
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                }
            } else {
                return;
            }
        } catch (TException e) {
            LOG.info("TopicAndPartition: " + topicAndPartition + " fetchMessage with startMessageOffset: " + nextMessageOffset + " failed", e);
            exception = e;
            ++retryTimes;
        }
    }
    throw new IOException("TopicAndPartition: " + topicAndPartition + " fetchMessage with startMessageOffset: " + nextMessageOffset + " failed", exception);
}

[Buggy Hunk]
int fetchMessageNumber = (int)(inputSplit.getEndMessageOffset() - nextMessageOffset);

[Patch]
int fetchMessageNumber = (int)(inputSplit.getEndMessageOffset() - nextMessageOffset + 1);

[Demonstration 3]

[Buggy Method]
private Bitmap createClippedBitmap() {
    if (mSampleSize <= 1) {
        return mClipImageView.clip();
    }
    // 获取缩放位移后的矩阵值
    final float[] matrixValues = mClipImageView.getClipMatrixValues();
    final float scale = matrixValues[Matrix.MSCALE_X];
    final float transX = matrixValues[Matrix.MTRANS_X];
    final float transY = matrixValues[Matrix.MTRANS_Y];
    // 获取在显示的图片中裁剪的位置
    final Rect border = mClipImageView.getClipBorder();
    final float cropX = ((-transX + border.left) / scale) * mSampleSize;
    final float cropY = ((-transY + border.top) / scale) * mSampleSize;
    final float cropWidth = (border.width() / scale) * mSampleSize;
    final float cropHeight = (border.height() / scale) * mSampleSize;
    // 获取在旋转之前的裁剪位置
    final RectF srcRect = new RectF(cropX, cropY, cropX + cropWidth, cropY + cropHeight);
    final Rect clipRect = getRealRect(srcRect);
    final BitmapFactory.Options ops = new BitmapFactory.Options();
    final Matrix outputMatrix = new Matrix();
    outputMatrix.setRotate(mDegree);
    // 如果裁剪之后的图片宽高仍然太大,则进行缩小
    if (mMaxWidth > 0 && cropWidth > mMaxWidth) {
        ops.inSampleSize = findBestSample((int) cropWidth, mMaxWidth);
        final float outputScale = mMaxWidth / (cropWidth / ops.inSampleSize);
        outputMatrix.postScale(outputScale, outputScale);
    }
    // 裁剪
    BitmapRegionDecoder decoder = null;
    try {
        decoder = BitmapRegionDecoder.newInstance(mInput, false);
        final Bitmap source = decoder.decodeRegion(clipRect, ops);
        recycleImageViewBitmap();
        return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), outputMatrix, false);
    } catch (Exception e) {
        return mClipImageView.clip();
    } finally {
        if (decoder != null && !decoder.isRecycled()) {
            decoder.recycle();
        }
    }
}

[Buggy Hunk]
ops.inSampleSize = findBestSample((int) cropWidth, mMaxWidth);

[Patch]
ops.inSampleSize = ImageUtils.findBestSample((int) cropWidth, mMaxWidth);