[Demonstration 1]

[Buggy Method]
private VBox createLayout() {
    HBox hBox = new HBox();
    HBox.setHgrow(m_browserPane, Priority.ALWAYS);
    hBox.getChildren().addAll(m_settingPane, m_browserPane);
    VBox mainVbox = new VBox();
    VBox.setVgrow(hBox, Priority.ALWAYS);
    mainVbox.getChildren().addAll(m_urlPane, m_pathPane, hBox, m_logPane);
    return mainVbox;
}

[Buggy Hunk]
hBox.getChildren().addAll(m_settingPane, m_browserPane);

[Patch]
hBox.getChildren().addAll(m_browserPane);

[Demonstration 2]

[Buggy Method]
public Message receive() throws IOException {
    try {
        return (Message) messageIn.readObject();
    } catch (ClassNotFoundException ex) {
        System.err.println("ClassNotFoundException when decoding an object from the socket stream.");
        assert false;
        return null;
    }
}

[Buggy Hunk]
public Message receive() throws IOException {

[Patch]
public Message receive() throws SocketTimeoutException, IOException {

[Demonstration 3]

[Buggy Method]
@Override
protected Movie[] doInBackground(Void... params) {
    // 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 moviesJson = null;
    try {
        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
        String sortOrder = sharedPref.getString(SettingsActivity.KEY_PREF_SORT_ORDER, "");
        // Construct the URL for the TheMovieDB query
        final String MOVIE_BASE_URL = "https://api.themoviedb.org/3/movie/" + sortOrder + "?";
        final String APIKEY_PARAM = "api_key";
        Uri builtUri = Uri.parse(MOVIE_BASE_URL).buildUpon().appendQueryParameter(APIKEY_PARAM, BuildConfig.THE_MOVIE_DB_API_KEY).build();
        URL url = new URL(builtUri.toString());
        Log.v(LOG_TAG, "Built URI " + builtUri.toString());
        // Create the request to TheMovieDb, 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;
        }
        moviesJson = buffer.toString();
        Log.v(LOG_TAG, "Movies Json String: " + moviesJson);
    } catch (IOException e) {
        Log.e(LOG_TAG, "Error ", e);
        // If the code didn't successfully get the movies data, there's no point in attemping
        // to parse it.
        return null;
    } finally {
        if (urlConnection != null) {
            urlConnection.disconnect();
        }
        if (reader != null) {
            try {
                reader.close();
            } catch (final IOException e) {
                Log.e(LOG_TAG, "Error closing stream", e);
            }
        }
    }
    try {
        return getMovieDataFromJson(moviesJson);
    } catch (JSONException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        e.printStackTrace();
    }
    // This will only happen if there was an error getting or parsing the json.
    return null;
}

[Buggy Hunk]
String sortOrder = sharedPref.getString(SettingsActivity.KEY_PREF_SORT_ORDER, "");

[Patch]
String sortOrder = sharedPref.getString(SettingsActivity.KEY_PREF_SORT_ORDER, getString(R.string.pref_sort_order_default));