[Demonstration 1]

[Buggy Method]
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.e(TAG, "entered onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //showing all wines from db
    ArrayAdapter<String> adapter;
    Cursor c = db.getAllItems();
    ArrayList<String> items = new ArrayList<String>();
    try {
        if (c.moveToFirst()) {
            do {
                items.add(c.getString(c.getColumnIndexOrThrow(DatabaseTable.COL_WINE)));
            } while (c.moveToNext());
        }
        c.close();
        adapter = new ArrayAdapter<String>(this, R.layout.list_wine, items);
    } catch (RuntimeException e) {
    } finally {
        adapter = new ArrayAdapter<String>(this, R.layout.list_wine, WHITE_WINES);
    }
    // ListView listView = getListView();
    // the following two lines are replacements for commented out code
    listView = (ListView) findViewById(R.id.listView);
    listView.setAdapter(adapter);
    listView.setTextFilterEnabled(true);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // When clicked, show a toast with the TextView text
            Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
        }
    });
    Log.e(TAG, "onCreate success");
}

[Buggy Hunk]
Cursor c = db.getAllItems();

[Patch]
Cursor c = maindb.getAllItems();

[Demonstration 2]

[Buggy Method]
protected void updateStorage(String pid, String factoryPid, TypedProperties props, boolean append) throws Exception {
    if (storage != null && configCfgStore) {
        // get the cfg file
        File cfgFile;
        if (factoryPid != null) {
            cfgFile = new File(storage, pid + "-" + factoryPid + ".cfg");
        } else {
            cfgFile = new File(storage, pid + ".cfg");
        }
        Configuration cfg = findExistingConfiguration(configAdmin, factoryPid, pid);
        // update the cfg file depending of the configuration
        if (cfg != null && cfg.getProperties() != null) {
            Object val = cfg.getProperties().get(FILEINSTALL_FILE_NAME);
            try {
                if (val instanceof URL) {
                    cfgFile = new File(((URL) val).toURI());
                }
                if (val instanceof URI) {
                    cfgFile = new File((URI) val);
                }
                if (val instanceof String) {
                    cfgFile = new File(new URL((String) val).toURI());
                }
            } catch (Exception e) {
                throw new IOException(e.getMessage(), e);
            }
        }
        LOGGER.trace("Update {}", cfgFile.getName());
        // update the cfg file
        if (!cfgFile.exists()) {
            props.save(cfgFile);
        } else {
            TypedProperties properties = new TypedProperties();
            properties.load(cfgFile);
            for (String key : props.keySet()) {
                if (!Constants.SERVICE_PID.equals(key) && !ConfigurationAdmin.SERVICE_FACTORYPID.equals(key) && !FILEINSTALL_FILE_NAME.equals(key)) {
                    List<String> comments = props.getComments(key);
                    List<String> value = props.getRaw(key);
                    if (!properties.containsKey(key)) {
                        properties.put(key, comments, value);
                    } else if (!append) {
                        if (comments.isEmpty()) {
                            comments = properties.getComments(key);
                        }
                        properties.put(key, comments, value);
                    }
                }
            }
            if (!append) {
                // remove "removed" properties from the cfg file
                ArrayList<String> propertiesToRemove = new ArrayList<>();
                for (String key : properties.keySet()) {
                    if (!props.containsKey(key) && !Constants.SERVICE_PID.equals(key) && !ConfigurationAdmin.SERVICE_FACTORYPID.equals(key) && !FILEINSTALL_FILE_NAME.equals(key)) {
                        propertiesToRemove.add(key);
                    }
                }
                for (String key : propertiesToRemove) {
                    properties.remove(key);
                }
            }
            // save the cfg file
            storage.mkdirs();
            properties.save(cfgFile);
        }
    }
}

[Buggy Hunk]
Configuration cfg = findExistingConfiguration(configAdmin, factoryPid, pid);

[Patch]
Configuration cfg = findExistingConfiguration(configAdmin, pid, factoryPid);

[Demonstration 3]

[Buggy Method]
@Override
public void onLogout() {
    this.apiKey = empty();
}

[Buggy Hunk]
this.apiKey = empty();

[Patch]
this.apiKey = Optional.absent();