[Demonstration 1]

[Buggy Method]
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    //pass if not reflected to methods
    if (!(handler instanceof HandlerMethod)) {
        return true;
    }
    HandlerMethod handlerMethod = (HandlerMethod) handler;
    Method method = handlerMethod.getMethod();
    //get token from request header
    String authorization = request.getHeader(Constants.HEADER_TOKEN);
    //check token
    TokenModel model = tokenManager.getAdminToken(authorization);
    if (tokenManager.checkAdminToken(model)) {
        request.setAttribute(Constants.CURRENT_USER_ID, model.getUserId());
        return true;
    }
    //if checkToken fails and the method was annotated with Authorization return 401
    if (method.getAnnotation(Authorization.class) != null) {
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        return false;
    }
    return true;
}

[Buggy Hunk]
if(method.getAnnotation(Authorization.class) != null){

[Patch]
if(method.getAnnotation(AdminAuthorization.class) != null){

[Demonstration 2]

[Buggy Method]
private Exertion dispatchExertion(ServiceExertion exertion, String providerName) throws ExertionException, ExecutionException {
    Signature signature = exertion.getProcessSignature();
    Object provider = null;
    try {
        // If the exertion is a job rearrange the inner exertions to make sure the
        // dependencies are not broken
        if (exertion.isJob()) {
            ExertionSorter es = new ExertionSorter(exertion);
            exertion = (ServiceExertion) es.getSortedJob();
        }
        //			 exert modeling tasks
        if (exertion instanceof ModelingTask && exertion.getFidelity().getSelects().size() == 1) {
            return ((Task) exertion).doTask(transaction);
        }
        // handle delegated tasks with fidelities
        if (exertion.getClass() == Task.class) {
            if (exertion.getFidelity().getSelects().size() == 1) {
                return ((Task) exertion).doTask(transaction);
            } else {
                try {
                    return new ControlFlowManager().doTask((Task) exertion);
                } catch (ContextException e) {
                    e.printStackTrace();
                    throw new ExertionException(e);
                }
            }
        }
        // exert object tasks and jobs
        if (!(signature instanceof NetSignature)) {
            if (exertion instanceof Task) {
                if (exertion.getFidelity().getSelects().size() == 1) {
                    return ((Task) exertion).doTask(transaction);
                } else {
                    try {
                        return new ControlFlowManager().doTask((Task) exertion);
                    } catch (ContextException e) {
                        e.printStackTrace();
                        throw new ExertionException(e);
                    }
                }
            } else if (exertion instanceof Job) {
                return ((Job) exertion).doJob(transaction);
            } else if (exertion instanceof Block) {
                return ((Block) exertion).doBlock(transaction);
            }
        }
        // check for missing signature of inconsistent PULL/PUSH cases
        logger.info("signature (before) = {}", signature);
        signature = correctProcessSignature();
        logger.info("signature (after)  = {}", signature);
        if (!((ServiceSignature) signature).isSelectable()) {
            exertion.reportException(new ExertionException("No such operation in the requested signature: " + signature));
            logger.warn("Not selectable exertion operation: " + signature);
            return exertion;
        }
        if (providerName != null && providerName.length() > 0) {
            signature.setProviderName(providerName);
        }
        if (logger.isDebugEnabled())
            logger.debug("ServiceShell's service accessor: {}", Accessor.get().getClass().getName());
        // if space exertion should go to Spacer
        if (!exertion.isJob() && exertion.getControlContext().getAccessType() == Access.PULL) {
            signature = new NetSignature("exert", Spacer.class, Sorcer.getActualSpacerName());
            exertion.correctProcessSignature(signature);
        }
        provider = ((NetSignature) signature).getProvider();
        if (provider == null) {
            // check proxy cache amd ping with a provider name
            try {
                provider = proxies.get(signature);
                ((Provider) provider).getProviderName();
            } catch (RuntimeException e) {
                proxies.refresh(signature);
                provider = proxies.get(signature);
            }
            if (provider == null) {
                String message = String.format("Provider name: [%s], type: %s not found, make sure it is running and there is " + "an available lookup service with correct discovery settings", signature.getProviderName(), signature.getServiceType().getName());
                logger.error(message);
                throw new ExertionException(message);
            }
            // lookup proxy
            /*if (provider == null) {
					long t0 = System.currentTimeMillis();
					provider = Accessor.get().getService(signature);
					if (logger.isDebugEnabled())
					 logger.info("Return from Accessor.getService(), round trip: {} millis",
							 (System.currentTimeMillis() - t0));
				}*/
        }
    } catch (Exception e) {
        throw new ExertionException(e);
    }
    if (provider != null) {
        if (provider instanceof Provider) {
            // cache the provider for the signature
            ((NetSignature) signature).setProvider((Provider) provider);
            //				if (proxies != null)
            //					proxies.put(signature, provider);
        } else if (exertion instanceof Task) {
            // exert smart proxy as an object task delegate
            try {
                ObjectSignature sig = new ObjectSignature();
                sig.setSelector(signature.getSelector());
                sig.setTarget(provider);
                Context cxt = exertion.getContext();
                ((Task) exertion).setDelegate(new ObjectTask(sig, cxt));
                return ((Task) exertion).doTask(transaction);
            } catch (Exception e) {
                throw new ExertionException(e);
            }
        }
    }
    this.provider = (Provider) provider;
    // continue exerting
    return null;
}

[Buggy Hunk]
} catch(RuntimeException e) {

[Patch]
} catch(Exception e) {

[Demonstration 3]

[Buggy Method]
protected Integer doInBackground(String... params) {
    Long expected_total_wb_nums = -1L;
    Long actually_total_wb_nums = 0L;
    String url = "https://api.weibo.com/2/statuses/user_timeline.json?" + "access_token=" + WeiboConfiguration.ACCESS_TOKEN + "&feature=1" + "&trim_user=1";
    //+ "&max_id=3923924100210158"
    mResult = HttpsUtil.HttpsPost(url, null);
    //Log.v(TAG, "WeiBo Sync:" + mResult);
    DataSource_WB dsw = new DataSource_WB(mContext);
    try {
        dsw.openForWrite();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    do {
        try {
            JSONObject jsonObject = new JSONObject(mResult);
            if (expected_total_wb_nums != -1L) {
                //TODO:Only show one line first
                expected_total_wb_nums = Long.parseLong(jsonObject.getString("total_number"));
            }
            Long next_wb_id = Long.parseLong(jsonObject.getString("next_cursor"));
            JSONArray jsonArray = jsonObject.getJSONArray("statuses");
            int len = jsonArray.length();
            for (int i = 0; i < len; i++) {
                JSONObject jb = (JSONObject) jsonArray.opt(i);
                String date = jb.getString("created_at");
                Long id = jb.getLong("id");
                String text = jb.getString("text");
                actually_total_wb_nums++;
                Log.v(TAG, "Index " + actually_total_wb_nums + ":" + date + ">>ID:" + id + ">>" + text);
                // add one weibo message into db as one record
                DataModel_WB dmw = new DataModel_WB();
                dmw.setWBId(id);
                dmw.setContent(text);
                dmw.setCreatedDate(date);
                DataModel_WB ret = dsw.createRecord(dmw);
                Log.v(TAG, "Insert record ok:" + date + ">>ID:" + id + ">>" + text);
            }
            //
            // get next 5 messages based on 'next_cursor' by specifying max_id in HTTP GET method
            //
            mResult = HttpsUtil.HttpsPost(url + "&max_id=" + next_wb_id, null);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    } while (actually_total_wb_nums < expected_total_wb_nums);
    dsw.close();
    return (mResult == null ? 0 : 1);
}

[Buggy Hunk]
if (expected_total_wb_nums != -1L) { //TODO:Only show one line first

[Patch]
if (expected_total_wb_nums == -1L) { //TODO:Only show one line first