[Demonstration 1]

[Buggy Method]
static void getQuotes(Context context) {
    Timber.d("Running sync job");
    Calendar from = Calendar.getInstance();
    Calendar to = Calendar.getInstance();
    from.add(Calendar.YEAR, -YEARS_OF_HISTORY);
    try {
        Set<String> stockPref = PrefUtils.getStocks(context);
        Set<String> stockCopy = new HashSet<>();
        stockCopy.addAll(stockPref);
        String[] stockArray = stockPref.toArray(new String[stockPref.size()]);
        Timber.d(stockCopy.toString());
        if (stockArray.length == 0) {
            return;
        }
        Map<String, Stock> quotes = YahooFinance.get(stockArray);
        Iterator<String> iterator = stockCopy.iterator();
        Timber.d(quotes.toString());
        ArrayList<ContentValues> quoteCVs = new ArrayList<>();
        while (iterator.hasNext()) {
            String symbol = iterator.next();
            Stock stock = quotes.get(symbol);
            StockQuote quote = stock.getQuote();
            if (quote.getPrice() != null) {
                float price = quote.getPrice().floatValue();
                float change = quote.getChange().floatValue();
                float percentChange = quote.getChangeInPercent().floatValue();
                // WARNING! Don't request historical data for a stock that doesn't exist!
                // The request will hang forever X_x
                List<HistoricalQuote> history = stock.getHistory(from, to, Interval.WEEKLY);
                StringBuilder historyBuilder = new StringBuilder();
                for (HistoricalQuote it : history) {
                    historyBuilder.append(it.getDate().getTimeInMillis());
                    historyBuilder.append(", ");
                    historyBuilder.append(it.getClose());
                    historyBuilder.append("\n");
                }
                ContentValues quoteCV = new ContentValues();
                quoteCV.put(Contract.Quote.COLUMN_SYMBOL, symbol);
                quoteCV.put(Contract.Quote.COLUMN_PRICE, price);
                quoteCV.put(Contract.Quote.COLUMN_PERCENTAGE_CHANGE, percentChange);
                quoteCV.put(Contract.Quote.COLUMN_ABSOLUTE_CHANGE, change);
                quoteCV.put(Contract.Quote.COLUMN_HISTORY, historyBuilder.toString());
                quoteCVs.add(quoteCV);
            }
        }
        context.getContentResolver().bulkInsert(Contract.Quote.URI, quoteCVs.toArray(new ContentValues[quoteCVs.size()]));
        Intent dataUpdatedIntent = new Intent(ACTION_DATA_UPDATED);
        context.sendBroadcast(dataUpdatedIntent);
    } catch (IOException exception) {
        Timber.e(exception, "Error fetching stock quotes");
    }
}

[Buggy Hunk]
} catch (IOException exception) {

[Patch]
} catch (IOException | NullPointerException | ArrayIndexOutOfBoundsException exception) {

[Demonstration 2]

[Buggy Method]
public void done(boolean successfullyCompleted) {
    this.successfullyCompleted = successfullyCompleted;
}

[Buggy Hunk]
this.successfullyCompleted = successfullyCompleted;

[Patch]
this.successfullyCompleted.set(successfullyCompleted);

[Demonstration 3]

[Buggy Method]
@Override
public Response toResponse(final Connect4RestException exception) {
    Response.Status status = null;
    if (exception.getCause() instanceof Connect4ServiceValidationException) {
        status = Status.BAD_REQUEST;
    } else if (exception.getCause() instanceof Connect4ServiceSystemException) {
        status = Status.INTERNAL_SERVER_ERROR;
    } else if (exception.getCause() instanceof GameSessionExistsServiceException) {
        status = Status.FORBIDDEN;
    } else if (exception.getCause() instanceof GameSessionNotFoundException) {
        status = Status.BAD_REQUEST;
    }
    return Response.status(status).entity(exception.getErrors()).build();
}

[Buggy Hunk]
} else if (exception.getCause() instanceof GameSessionNotFoundException) {

[Patch]
} else if (exception.getCause() instanceof GameSessionNotExistsException) {