[Demonstration 1]

[Buggy Method]
public static <T> void rangeEq(String name, T value, Comparable<T> min, Comparable<T> max) {
    if (min.compareTo(value) == 1 || max.compareTo(value) == -1) {
        String message = String.format("Expected %s <= %s <= %s, but %2$s was %s.", min, name, max, value);
        throw new IllegalArgumentException(message);
    }
}

[Buggy Hunk]
if (min.compareTo(value) == 1 || max.compareTo(value) == -1) {

[Patch]
if (0 < min.compareTo(value) || max.compareTo(value) < 0) {

[Demonstration 2]

[Buggy Method]
public PortfolioTotalStatus[] getPortfolioTotalStatus() {
    Portfolio portfolio = getPortfolio();
    Map<Date, Float> map = new HashMap<>();
    //get stock status from db.
    Stock[] stocks = portfolio.getStocks();
    for (int i = 0; i < stocks.length; i++) {
        Stock stock = stocks[i];
        if (stock != null) {
            List<StockStatus> history = datastoreService.getStockHistory(stock.getStockSymbol(), DAYS_BACK);
            for (int j = 0; j < history.size(); j++) {
                StockStatus curr = history.get(j);
                Date date = dateMidnight(curr.getDate());
                float value = curr.getBid() * curr.getStockQuantity();
                Float total = map.get(date);
                if (total == null) {
                    total = value;
                } else {
                    total += value;
                }
                map.put(date, value);
            }
        }
    }
    PortfolioTotalStatus[] ret = new PortfolioTotalStatus[map.size()];
    int index = 0;
    //create dto objects
    for (Date date : map.keySet()) {
        ret[index] = new PortfolioTotalStatus(date, map.get(date));
        index++;
    }
    //sort by date ascending.
    Arrays.sort(ret);
    return ret;
}

[Buggy Hunk]
List<StockStatus> history = datastoreService.getStockHistory(stock.getStockSymbol(), DAYS_BACK);

[Patch]
List<StockStatus> history = datastoreService.getStockHistory(stock.getSymbol(), DAYS_BACK);

[Demonstration 3]

[Buggy Method]
private void updateBluetoothTetherSummary() {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    String savedAddress = sharedPreferences.getString(getString(R.string.pref_bluetooth_tether_address), "");
    BluetoothDevice device = null;
    try {
        device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(savedAddress);
    } catch (IllegalArgumentException ignored) {
    }
    String deviceName = getActivity().getString(R.string.bluetooth_tether_no_device_set);
    if (device != null) {
        deviceName = device.getName();
    } else if (!savedAddress.isEmpty()) {
        // The previously saved devices has unpaired
        sharedPreferences.edit().putString(getString(R.string.pref_bluetooth_tether_address), "").apply();
    }
    bluetoothTetherPreference.setSummary(getString(R.string.bluetooth_tether_address_summary, deviceName));
}

[Buggy Hunk]
} catch (IllegalArgumentException ignored) {}

[Patch]
} catch (IllegalArgumentException | NullPointerException ignored) {}