[Demonstration 1]

[Buggy Method]
private void onDrawKeyboard(@NonNull final Canvas canvas) {
    final Keyboard keyboard = getKeyboard();
    if (keyboard == null) {
        return;
    }
    final Paint paint = mPaint;
    final Drawable background = getBackground();
    if (mCustomColorEnabled && keyboard.getKey(Constants.CODE_SPACE) != null) {
        setBackgroundColor(mCustomColor);
    }
    // Calculate clip region and set.
    final boolean drawAllKeys = mInvalidateAllKeys || mInvalidatedKeys.isEmpty();
    final boolean isHardwareAccelerated = canvas.isHardwareAccelerated();
    // TODO: Confirm if it's really required to draw all keys when hardware acceleration is on.
    if (drawAllKeys || isHardwareAccelerated) {
        if (!isHardwareAccelerated && background != null) {
            // Need to draw keyboard background on {@link #mOffscreenBuffer}.
            canvas.drawColor(Color.BLACK, PorterDuff.Mode.CLEAR);
            background.draw(canvas);
        }
        // Draw all keys.
        for (final Key key : keyboard.getSortedKeys()) {
            onDrawKey(key, canvas, paint);
        }
    } else {
        for (final Key key : mInvalidatedKeys) {
            if (!keyboard.hasKey(key)) {
                continue;
            }
            if (background != null) {
                // Need to redraw key's background on {@link #mOffscreenBuffer}.
                final int x = key.getX() + getPaddingLeft();
                final int y = key.getY() + getPaddingTop();
                mClipRect.set(x, y, x + key.getWidth(), y + key.getHeight());
                canvas.save();
                canvas.clipRect(mClipRect);
                canvas.drawColor(Color.BLACK, PorterDuff.Mode.CLEAR);
                background.draw(canvas);
                canvas.restore();
            }
            onDrawKey(key, canvas, paint);
        }
    }
    mInvalidatedKeys.clear();
    mInvalidateAllKeys = false;
}

[Buggy Hunk]
if (mCustomColorEnabled && keyboard.getKey(Constants.CODE_SPACE) != null) {

[Patch]
if (keyboard.getKey(Constants.CODE_SPACE) != null) {

[Demonstration 2]

[Buggy Method]
@Override
public void run() {
    server.start();
    try {
        /**
         * 不断的检查Agent服务(默认端口1577)有没有停止,由于当前的socketIO是另一个进程，确保在Agent服务停止的时候实时监控服务也可以停止,
         * 如果Agent在运行中,则hold住实时监控的进程,确保可以提供数据
         */
        while (agentIsRunning()) {
            Thread.sleep(10000);
        }
        server.stop();
    } catch (Exception ex) {
        // continue and check the flag
    }
}

[Buggy Hunk]
Thread.sleep(10000);

[Patch]
TimeUnit.MICROSECONDS.sleep(1000);

[Demonstration 3]

[Buggy Method]
public void run() {
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    System.out.println("Thread Three Starting: " + z);
}

[Buggy Hunk]
System.out.println("Thread Three Starting: " + z);

[Patch]
System.out.println("Thread Three Starting: " + array[2]);