[Demonstration 1]

[Buggy Method]
public void open() {
    Class.forName("com.mysql.jdbc.Driver");
    conn = DriverManager.getConnection("jdbc:mysql://cslvm74.csc.calpoly.edu/cjacob07", "cjacob07", "Ma94ne07k");
}

[Buggy Hunk]
public void open() {

[Patch]
public void open() throws Exception {

[Demonstration 2]

[Buggy Method]
private static URI urlToUri(final URL url) {
    try {
        return url.toURI();
    } catch (URISyntaxException e) {
        throw new IllegalStateException(format("Unable to convert URL %s to URI", url));
    }
}

[Buggy Hunk]
throw new IllegalStateException(format("Unable to convert URL %s to URI", url));

[Patch]
throw new IllegalStateException(format("Unable to convert URL %s to URI", url), e);

[Demonstration 3]

[Buggy Method]
@Override
public void onRefresh() {
    // Pulse haptic feedback.
    vibratorService.vibrate(Utility.HAPTIC_FEEDBACK_DURATION);
    // Using the Cursor from the list adapter, get and sync all the Monitors.
    if (Utility.hasNetworkConnection(MainActivity.this)) {
        final Cursor cursor = monitorAdapter.getCursor();
        cursor.moveToFirst();
        SyncStatusObserver observer = new SyncStatusObserver() {

            int numMonitors = cursor.getCount();

            @Override
            public void onStatusChanged(int which) {
                // Once all Monitors have finished syncing, remove the listener and stop
                // the refreshing animation.
                if (numMonitors <= 0) {
                    ContentResolver.removeStatusChangeListener(syncHandle);
                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            swipeContainer.setRefreshing(false);
                        }
                    });
                }
                // Check if any of the Monitors became active.
                List<SyncInfo> test = ContentResolver.getCurrentSyncs();
                for (SyncInfo syncInfo : test) {
                    if (syncInfo.authority.equals(getString(R.string.content_authority))) {
                        // Decrement the number of expected syncing Monitors.
                        numMonitors--;
                    }
                }
            }
        };
        syncHandle = ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE, observer);
        // Remove all the periodic syncs.
        List<String> urls = new ArrayList<>();
        List<Integer> ids = new ArrayList<>();
        List<Integer> frequencies = new ArrayList<>();
        do {
            String url = cursor.getString(cursor.getColumnIndex(MonitorEntry.URL));
            urls.add(url);
            Integer id = cursor.getInt(cursor.getColumnIndex(MonitorEntry._ID));
            ids.add(id);
            int frequency = cursor.getInt(cursor.getColumnIndex(MonitorEntry.PING_FREQUENCY));
            frequencies.add(frequency);
            // Only remove and create a new periodic sync if the Monitor is set to automatically sync.
            if (frequency < MonitorEntry.PING_FREQUENCY_MAX) {
                PingSyncAdapter.removePeriodicSync(MainActivity.this, url, id);
            }
        } while (cursor.moveToNext());
        // Recreate the periodic syncs. The Monitors will also be synced during this process.
        Account syncAccount = PingSyncAdapter.getSyncAccount(MainActivity.this);
        for (int i = 0; i < ids.size(); i++) {
            if (frequencies.get(i) < MonitorEntry.PING_FREQUENCY_MAX) {
                PingSyncAdapter.createPeriodicSync(MainActivity.this, urls.get(i), ids.get(i), frequencies.get(i));
            } else {
                PingSyncAdapter.syncImmediately(MainActivity.this, syncAccount, urls.get(i), ids.get(i));
            }
        }
    } else {
        Toast.makeText(MainActivity.this, getString(R.string.error_poor_connection), Toast.LENGTH_LONG).show();
    }
}

[Buggy Hunk]
frequencies.get(i));

[Patch]
(int) TimeUnit.MINUTES.toSeconds(Utility.PING_FREQUENCY_MINUTES[frequencies.get(i)]));