[Demonstration 1]

[Buggy Method]
@Override
public void startDocument() throws SAXException {
    if (shouldWrite)
        writer.startDocument();
}

[Buggy Hunk]
if (shouldWrite)

[Patch]
if (shouldWrite && mode == WriteMode.HEAD)

[Demonstration 2]

[Buggy Method]
public static Result service(String ownerName, String projectName, String service, boolean isAdvertise) throws IOException, UnsupportedOperationException, ServletException {
    if (!isSupportedService(service)) {
        return forbidden(String.format("Unsupported service: '%s'", service));
    }
    Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
    if (project == null) {
        return notFound();
    }
    models.User user = UserApp.currentUser();
    if (!isAllowed(project, service)) {
        if (user.isAnonymous()) {
            return BasicAuthAction.unauthorized(response());
        } else {
            // If you want the Git client showing your custom message to
            // the user, the Content-Type should be exact "text/plain"
            // without any parameter. For more details, see the code at
            // https://github.com/git/git/commit/426e70d4a11ce3b4f70636d57c6a0ab16ae08a00#diff-eea0ad565ec5903a11b6023755d491cfR154
            response().setHeader("Content-Type", "text/plain");
            return forbidden(String.format("'%s' has no permission to '%s/%s'.", user.name, ownerName, projectName));
        }
    }
    if (isAdvertise) {
        return ok(RepositoryService.gitAdvertise(project, service, response()));
    } else {
        if (request().body().isMaxSizeExceeded()) {
            return status(REQUEST_ENTITY_TOO_LARGE);
        } else {
            user.visits(project);
            return ok(RepositoryService.gitRpc(project, service, request(), response()));
        }
    }
}

[Buggy Hunk]
user.name, ownerName, projectName));

[Patch]
user.loginId, ownerName, projectName));

[Demonstration 3]

[Buggy Method]
@Override
public void run() {
    Frame outputFrame;
    ByteBuffer data;
    while (true) {
        synchronized (mLock) {
            if (mActive && (mPendingFrameData == null)) {
                try {
                    // Wait for the next frame to be received from the camera, since we
                    // don't have it yet.
                    mLock.wait();
                } catch (InterruptedException e) {
                    Log.d(TAG, "Frame processing loop terminated.", e);
                    return;
                }
            }
            if (!mActive) {
                // Exit the loop once this camera source is stopped or released.  We check
                // this here, immediately after the wait() above, to handle the case where
                // setActive(false) had been called, triggering the termination of this
                // loop.
                return;
            }
            outputFrame = new Frame.Builder().setImageData(mPendingFrameData, mPreviewSize.getWidth(), mPreviewSize.getHeight(), ImageFormat.NV21).setId(mPendingFrameId).setTimestampMillis(mPendingTimeMillis).setRotation(mRotation).build();
            // Hold onto the frame data locally, so that we can use this for detection
            // below.  We need to clear mPendingFrameData to ensure that this buffer isn't
            // recycled back to the camera before we are done using that data.
            data = mPendingFrameData;
            mPendingFrameData = null;
        }
        // The code below needs to run outside of synchronization, because this will allow
        // the camera to add pending frame(s) while we are running detection on the current
        // frame.
        try {
            mDetector.receiveFrame(outputFrame);
        } catch (Throwable t) {
            Log.e(TAG, "Exception thrown from receiver.", t);
        } finally {
            mCamera.addCallbackBuffer(data.array());
        }
    }
}

[Buggy Hunk]
if (mActive && (mPendingFrameData == null)) {

[Patch]
while (mActive && (mPendingFrameData == null)) {