[Demonstration 1]

[Buggy Method]
@Override
public void updateUserId(String id, String oldUserId, String newUserId) {
    if (!JocketStringUtil.isEmpty(oldUserId)) {
        String key = getUserKey(oldUserId);
        JocketRedisExecutor.srem(key, id);
    }
    if (!JocketStringUtil.isEmpty(newUserId)) {
        String key = getUserKey(oldUserId);
        JocketRedisExecutor.sadd(key, id);
    }
}

[Buggy Hunk]
String key = getUserKey(oldUserId);

[Patch]
String key = getUserKey(newUserId);

[Demonstration 2]

[Buggy Method]
private void bind() {
    if (mContext == null) {
        Log.e(TAG, "No context for binding");
        return;
    }
    Intent intent = new Intent();
    intent.setClassName(PAC_PACKAGE, PAC_SERVICE);
    if ((mProxyConnection != null) && (mConnection != null)) {
        // Already bound no need to bind again, just download the new file.
        IoThread.getHandler().post(mPacDownloader);
        return;
    }
    mConnection = new ServiceConnection() {

        @Override
        public void onServiceDisconnected(ComponentName component) {
            synchronized (mProxyLock) {
                mProxyService = null;
            }
        }

        @Override
        public void onServiceConnected(ComponentName component, IBinder binder) {
            synchronized (mProxyLock) {
                try {
                    Log.d(TAG, "Adding service " + PAC_SERVICE_NAME + " " + binder.getInterfaceDescriptor());
                } catch (RemoteException e1) {
                    Log.e(TAG, "Remote Exception", e1);
                }
                ServiceManager.addService(PAC_SERVICE_NAME, binder);
                mProxyService = IProxyService.Stub.asInterface(binder);
                if (mProxyService == null) {
                    Log.e(TAG, "No proxy service");
                } else {
                    try {
                        mProxyService.startPacSystem();
                    } catch (RemoteException e) {
                        Log.e(TAG, "Unable to reach ProxyService - PAC will not be started", e);
                    }
                    IoThread.getHandler().post(mPacDownloader);
                }
            }
        }
    };
    mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_VISIBLE);
    intent = new Intent();
    intent.setClassName(PROXY_PACKAGE, PROXY_SERVICE);
    mProxyConnection = new ServiceConnection() {

        @Override
        public void onServiceDisconnected(ComponentName component) {
        }

        @Override
        public void onServiceConnected(ComponentName component, IBinder binder) {
            IProxyCallback callbackService = IProxyCallback.Stub.asInterface(binder);
            if (callbackService != null) {
                try {
                    callbackService.getProxyPort(new IProxyPortListener.Stub() {

                        @Override
                        public void setProxyPort(int port) throws RemoteException {
                            if (mLastPort != -1) {
                                // Always need to send if port changed
                                mHasSentBroadcast = false;
                            }
                            mLastPort = port;
                            if (port != -1) {
                                Log.d(TAG, "Local proxy is bound on " + port);
                                sendProxyIfNeeded();
                            } else {
                                Log.e(TAG, "Received invalid port from Local Proxy," + " PAC will not be operational");
                            }
                        }
                    });
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }
    };
    mContext.bindService(intent, mProxyConnection, Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_VISIBLE);
}

[Buggy Hunk]
IoThread.getHandler().post(mPacDownloader);

[Patch]
mNetThreadHandler.post(mPacDownloader);

[Demonstration 3]

[Buggy Method]
private void login() {
    if (!validate()) {
        final RegisterInfo info = new RegisterInfo();
        info.setPhone(this.tvAuto.getText().toString());
        info.setPassword(this.etPassword.getText().toString());
        new BaseHttpAsyncTask<Object, Object, Object>(getActivity(), false) {

            @Override
            protected void onCompleteTask(Object paramResult) {
                if (paramResult != null) {
                    RegisterInfo info = (RegisterInfo) paramResult;
                    MineFragment.this.activity.deleteAllPreference("COMMON");
                    MineFragment.this.activity.writePreference(Constants.STR_LOGIN, "true");
                    MineFragment.this.activity.writePreference(Key.GENDER, info.getGender());
                    MineFragment.this.activity.writePreference(Key.PHONE, info.getPhone());
                    MineFragment.this.activity.writePreference(Key.PROVINCE, info.getProvince());
                    MineFragment.this.activity.writePreference(Key.CITY, info.getCity());
                    MineFragment.this.activity.writePreference(Key.NICKNAME, info.getNickname());
                    MineFragment.this.activity.showMyToast("登录成功");
                } else {
                    MineFragment.this.activity.showMyToast("账号填写有误,请检查后重新填写");
                }
            }

            @Override
            protected Object run(Object[] paramArrayOfParams) {
                return UserInfoDBHandler.getInstance().login(info);
            }
        }.execute();
    }
}

[Buggy Hunk]
if (!validate()) {

[Patch]
if (validate()) {