[Demonstration 1]

[Buggy Method]
public void importCallInfo(String file) {
    try {
        FileInputStream fis = new FileInputStream(file);
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        XmlPullParser parser = factory.newPullParser();
        parser.setInput(fis, "utf-8");
        int eventType = parser.getEventType();
        ContactInfo info = null;
        String tagName = null;
        String text = null;
        RecordInfo recordInfo = null;
        ArrayList<RecordInfo> recordList = new ArrayList<RecordInfo>();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_DOCUMENT) {
                Log.d(Log.TAG, "Start Document");
            } else if (eventType == XmlPullParser.START_TAG) {
                tagName = parser.getName();
                parser.next();
                text = parser.getText();
                // Log.d(Log.TAG, tagName + " : " + text);
                if ("count".equals(tagName)) {
                    int count = parseInt(text);
                    if (mOnImportExportListener != null) {
                        mOnImportExportListener.onStart(count);
                    }
                } else if ("contact".equalsIgnoreCase(tagName)) {
                    info = new ContactInfo();
                    recordList.clear();
                } else if ("contact_name".equalsIgnoreCase(tagName)) {
                    info.name = text;
                } else if ("contact_sex".equalsIgnoreCase(tagName)) {
                    info.sex = parseInt(text);
                } else if ("contact_age".equalsIgnoreCase(tagName)) {
                    info.age = parseInt(text);
                } else if ("contact_address".equalsIgnoreCase(tagName)) {
                    info.address = text;
                } else if ("contact_number".equalsIgnoreCase(tagName)) {
                    info.number = text;
                } else if ("contact_call_log_count".equalsIgnoreCase(tagName)) {
                    info.calllogcount = parseInt(text);
                } else if ("contact_allow_record".equalsIgnoreCase(tagName)) {
                    info.allowrecord = parseInt(text);
                } else if ("contact_state".equalsIgnoreCase(tagName)) {
                    info.callstate = text;
                } else if ("contact_update".equalsIgnoreCase(tagName)) {
                    info.update = parseInt(text);
                } else if ("contact_allow_modify".equalsIgnoreCase(tagName)) {
                    info.allowmodify = parseInt(text);
                } else if ("foo".equalsIgnoreCase(tagName)) {
                    info.foo = text;
                } else if ("record".equalsIgnoreCase(tagName)) {
                    recordInfo = new RecordInfo();
                } else if ("record_name".equalsIgnoreCase(tagName)) {
                    recordInfo.recordname = text;
                } else if ("record_file".equalsIgnoreCase(tagName)) {
                    recordInfo.recordfile = text;
                } else if ("record_number".equalsIgnoreCase(tagName)) {
                    recordInfo.recordnumber = text;
                } else if ("record_flag".equalsIgnoreCase(tagName)) {
                    recordInfo.recordflag = parseInt(text);
                } else if ("record_size".equalsIgnoreCase(tagName)) {
                    recordInfo.recordsize = parseLong(text);
                } else if ("record_ring".equalsIgnoreCase(tagName)) {
                    recordInfo.recordring = parseLong(text);
                } else if ("record_start".equalsIgnoreCase(tagName)) {
                    recordInfo.recordstart = parseLong(text);
                } else if ("record_end".equalsIgnoreCase(tagName)) {
                    recordInfo.recordend = parseLong(text);
                } else if ("foo".equalsIgnoreCase(tagName)) {
                    recordInfo.foo = text;
                }
            } else if (eventType == XmlPullParser.END_TAG) {
                tagName = parser.getName();
                if ("record".equalsIgnoreCase(tagName)) {
                    recordList.add(recordInfo);
                } else if ("contact".equalsIgnoreCase(tagName)) {
                    int _id = addOrUpdateContactInfo(info);
                    Log.d(Log.TAG, "_id : " + _id);
                    addOrThrowRecordInfo(_id, recordList);
                    if (mOnImportExportListener != null) {
                        String statusText = info.name;
                        if (TextUtils.isEmpty(statusText)) {
                            statusText = info.number;
                        }
                        mOnImportExportListener.onProcessing(statusText);
                        try {
                            Thread.sleep(50);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
            eventType = parser.next();
        }
        Log.d(Log.TAG, "End Document");
        if (mOnImportExportListener != null) {
            mOnImportExportListener.onEnd();
        }
    } catch (XmlPullParserException e) {
    } catch (Exception e) {
    }
}

[Buggy Hunk]
info.update = parseInt(text);

[Patch]
info.update = parseLong(text);

[Demonstration 2]

[Buggy Method]
protected void addField(XContentBuilder xContentBuilder, Field field) throws IOException {
    String name = field.getName();
    if (!field.isLocalized()) {
        String[] values = field.getValues();
        if (ArrayUtil.isEmpty(values)) {
            return;
        }
        List<String> valuesList = new ArrayList<>(values.length);
        for (String value : values) {
            if (Validator.isNull(value)) {
                continue;
            }
            valuesList.add(value.trim());
        }
        if (valuesList.isEmpty()) {
            return;
        }
        values = valuesList.toArray(new String[valuesList.size()]);
        addField(xContentBuilder, field, name, values);
        if (field.isSortable()) {
            String sortFieldName = DocumentImpl.getSortableFieldName(name);
            addField(xContentBuilder, field, sortFieldName, values);
        }
    } else {
        Map<Locale, String> localizedValues = field.getLocalizedValues();
        for (Map.Entry<Locale, String> entry : localizedValues.entrySet()) {
            String value = entry.getValue();
            if (Validator.isNull(value)) {
                continue;
            }
            Locale locale = entry.getKey();
            String languageId = LocaleUtil.toLanguageId(locale);
            String defaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getDefault());
            value = value.trim();
            if (languageId.equals(defaultLanguageId)) {
                addField(xContentBuilder, field, name, value);
            }
            String localizedName = DocumentImpl.getLocalizedName(languageId, name);
            addField(xContentBuilder, field, localizedName, value);
            if (field.isSortable()) {
                String sortableFieldName = DocumentImpl.getSortableFieldName(localizedName);
                addField(xContentBuilder, field, sortableFieldName, value);
            }
        }
    }
}

[Buggy Hunk]
if (Validator.isNull(value)) {

[Patch]
if (value == null) {

[Demonstration 3]

[Buggy Method]
@Override
protected Void doInBackground(String... params) {
    // If there's no zip code, there's nothing to look up.  Verify size of params.
    if (params.length == 0) {
        return null;
    }
    String locationQuery = params[0];
    // These two need to be declared outside the try/catch
    // so that they can be closed in the finally block.
    HttpURLConnection urlConnection = null;
    BufferedReader reader = null;
    // Will contain the raw JSON response as a string.
    String forecastJsonStr = null;
    String format = "json";
    String units = "metric";
    int numDays = 14;
    try {
        // Construct the URL for the OpenWeatherMap query
        // Possible parameters are avaiable at OWM's forecast API page, at
        // http://openweathermap.org/API#forecast
        final String FORECAST_BASE_URL = "http://api.openweathermap.org/data/2.5/forecast/daily?";
        final String QUERY_PARAM = "q";
        final String FORMAT_PARAM = "mode";
        final String UNITS_PARAM = "units";
        final String DAYS_PARAM = "cnt";
        Uri builtUri = Uri.parse(FORECAST_BASE_URL).buildUpon().appendQueryParameter(QUERY_PARAM, params[0]).appendQueryParameter(FORMAT_PARAM, format).appendQueryParameter(UNITS_PARAM, units).appendQueryParameter(DAYS_PARAM, Integer.toString(numDays)).build();
        URL url = new URL(builtUri.toString());
        // Create the request to OpenWeatherMap, and open the connection
        urlConnection = (HttpURLConnection) url.openConnection();
        urlConnection.setRequestMethod("GET");
        urlConnection.connect();
        // Read the input stream into a String
        InputStream inputStream = urlConnection.getInputStream();
        StringBuffer buffer = new StringBuffer();
        if (inputStream == null) {
            // Nothing to do.
            return null;
        }
        reader = new BufferedReader(new InputStreamReader(inputStream));
        String line;
        while ((line = reader.readLine()) != null) {
            // Since it's JSON, adding a newline isn't necessary (it won't affect parsing)
            // But it does make debugging a *lot* easier if you print out the completed
            // buffer for debugging.
            buffer.append(line + "\n");
        }
        if (buffer.length() == 0) {
            // Stream was empty.  No point in parsing.
            return null;
        }
        forecastJsonStr = buffer.toString();
        getWeatherDataFromJson(forecastJsonStr, locationQuery);
    } catch (IOException e) {
        Log.e(LOG_TAG, "Error ", e);
        // If the code didn't successfully get the weather data, there's no point in attempting
        // to parse it.
    } catch (JSONException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        e.printStackTrace();
    } finally {
        if (urlConnection != null) {
            urlConnection.disconnect();
        }
        if (reader != null) {
            try {
                reader.close();
            } catch (final IOException e) {
                Log.e(LOG_TAG, "Error closing stream", e);
            }
        }
    }
    return null;
}

[Buggy Hunk]
protected Void doInBackground(String... params) {

[Patch]
protected String[] doInBackground(String... params) {