[Demonstration 1]

[Buggy Method]
private void getTasksByGroupName(int action, String groupName, int requestCode) {
    RenderCallback handler = mHandlers.get(Constant.RenderServiceHelper.ACTION.valueOf(action).toString());
    Cursor cursor;
    if (StringUtil.isEmpty(groupName)) {
        if (requestCode == Constant.RenderServiceHelper.REQUEST_CODE_GET_ALL_TASKS_BEANS_EXCEPT_FINISHED) {
            cursor = mDbReader.rawQuery("select * from " + Constant.RenderDbHelper.EXTRA_TABLE_NAME_TASKS + " where " + Constant.RenderDbHelper.EXTRA_TABLE_GROUP_COLUM_GROUP + " <> ? order by " + Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_TIMILLS, new String[] { Constant.RenderDbHelper.GROUP_NAME_FINISHED });
        } else {
            cursor = mDbReader.rawQuery("select * from " + Constant.RenderDbHelper.EXTRA_TABLE_NAME_TASKS + " order by " + Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_TIMILLS, null);
        }
    } else {
        cursor = mDbReader.rawQuery("select * from " + Constant.RenderDbHelper.EXTRA_TABLE_NAME_TASKS + " where " + Constant.RenderDbHelper.EXTRA_TABLE_GROUP_COLUM_GROUP + " = ? order by " + Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_TIMILLS, new String[] { groupName });
    }
    if (cursor != null && cursor.moveToFirst()) {
        List<TaskBean> renderObjectBeans = new RenderObjectBeans<TaskBean>();
        while (cursor.moveToNext()) {
            TaskBean taskBean = new TaskBean();
            taskBean.setTaskContent(cursor.getString(cursor.getColumnIndex(Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_CONTENT)));
            taskBean.setYear(cursor.getInt(cursor.getColumnIndex(Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_YEAR)));
            taskBean.setMonth(cursor.getInt(cursor.getColumnIndex(Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_MONTH)));
            taskBean.setDayOfMonth(cursor.getInt(cursor.getColumnIndex(Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_DAY_OF_MONTH)));
            taskBean.setHour(cursor.getInt(cursor.getColumnIndex(Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_HOUR)));
            taskBean.setMinuse(cursor.getInt(cursor.getColumnIndex(Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_MINUTE)));
            taskBean.setRepeatInterval(cursor.getInt(cursor.getColumnIndex(Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_REPEAT_INTERVAL)));
            taskBean.setRepeatUnit(cursor.getInt(cursor.getColumnIndex(Constant.RenderDbHelper.EXTRA_TABLE_TASKS_COLUM_REPEAT_UNIT)));
            taskBean.setGroup(cursor.getString(cursor.getColumnIndex(Constant.RenderDbHelper.EXTRA_TABLE_GROUP_COLUM_GROUP)));
            renderObjectBeans.add(taskBean);
            taskBean = null;
        }
        if (handler != null) {
            handler.onHandleSelectSuccess((RenderObjectBeans) renderObjectBeans, requestCode, Constant.RenderServiceHelper.RESULT_CODE_GET_TASKS_SUCCESS);
        }
    } else {
        if (handler != null) {
            handler.onHandleFail(requestCode, Constant.RenderServiceHelper.RESULT_CODE_GET_TASKS_FAIL_NO_TASKS);
        }
    }
    if (cursor != null) {
        cursor.close();
    }
}

[Buggy Hunk]
if (cursor != null && cursor.moveToFirst()) {

[Patch]
if (cursor != null) {

[Demonstration 2]

[Buggy Method]
public final Set<Class<? extends ParaObject>> getComponentClasses(String basePackage) {
    basePackage = (basePackage == null) ? "" : basePackage;
    Set<Class<? extends ParaObject>> classes = new HashSet<Class<? extends ParaObject>>();
    for (BeanDefinition candidate : findCandidateComponents(basePackage)) {
        try {
            Class<? extends ParaObject> cls = (Class<? extends ParaObject>) ClassUtils.resolveClassName(candidate.getBeanClassName(), Thread.currentThread().getContextClassLoader());
            classes.add(cls);
        } catch (Exception ex) {
            logger.error(null, ex);
        }
    }
    return classes;
}

[Buggy Hunk]
logger.error(null, ex);

[Patch]
LOG.error(null, ex);

[Demonstration 3]

[Buggy Method]
public List<DB_Location_NoeC> getAllFavoritLocations(int year) {
    List<DB_Location_NoeC> locationList = new ArrayList<DB_Location_NoeC>();
    // Select All Query
    String selectQuery = "SELECT  * FROM " + DB_Location_NoeC.TABLE_NAME + " WHERE " + DB_Location_NoeC.KEY_FAVORIT + "=1 AND " + DB_Location_NoeC.KEY_JAHR + "=" + String.valueOf(year) + " ORDER BY " + DB_Location_NoeC.KEY_NUMMER;
    SQLiteDatabase db = mDbHelper.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);
    // looping through all rows and adding to list
    if (cursor != null && cursor.moveToFirst()) {
        do {
            DB_Location_NoeC location = getLocationfromCursor(cursor);
            locationList.add(location);
        } while (cursor.moveToNext());
    }
    if (cursor != null) {
        cursor.close();
    }
    // Closing database connection
    db.close();
    return locationList;
}

[Buggy Hunk]
String selectQuery = "SELECT  * FROM " + DB_Location_NoeC.TABLE_NAME + " WHERE "+ DB_Location_NoeC.KEY_FAVORIT +"=1 AND "+DB_Location_NoeC.KEY_JAHR+"="+String.valueOf(year)+" ORDER BY "+DB_Location_NoeC.KEY_NUMMER;

[Patch]
String selectQuery = "SELECT  * FROM " + DB_Location_NoeC.TABLE_NAME + " WHERE "+ DB_Location_NoeC.KEY_FAVORIT +"=1 AND "+DB_Location_NoeC.KEY_JAHR+"="+String.valueOf(year)+" ORDER BY "+DB_Location_NoeC.KEY_NUMMER + "," + DB_Location_NoeC.KEY_NAME;