[Demonstration 1]

[Buggy Method]
@Override
public void execute(final TaskListener arg0) throws IOException, InterruptedException {
    LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: start");
    if (cloudNames != null && !cloudNames.isEmpty()) {
        // Walk the list of clouds and verify the configuration. If an element
        // is not found (perhaps a removed cloud, removes from the list)
        synchronized (cloudNamesLock) {
            List<String> toRemove = new ArrayList<String>();
            for (String cloudName : cloudNames) {
                LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: verifying cloud {0}", cloudName);
                AzureVMCloud cloud = getCloud(cloudName);
                // Unknown cloud.  Maybe the name changed since the cloud name
                // was registered.  Remove from the list
                if (cloud == null) {
                    LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: subscription {0} not found, skipping", cloudName);
                    // Remove
                    toRemove.add(cloudName);
                    continue;
                }
                // If already verified, skip
                if (cloud.isConfigurationValid()) {
                    LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: subscription {0} already verifed", cloudName);
                    // Update the count.
                    cloud.setVirtualMachineCount(getVirtualMachineCount(cloud));
                    continue;
                }
                // Verify.  Update the VM count before setting to valid
                if (verifyConfiguration(cloud)) {
                    LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: {0} verified", cloudName);
                    // Update the count
                    cloud.setVirtualMachineCount(getVirtualMachineCount(cloud));
                    // We grab the current VM count and
                    cloud.setConfigurationValid(true);
                    continue;
                }
                // Not valid!  Remains in list.
                LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: {0} not verified, has errors", cloudName);
            }
            // Remove items as necessary
            for (String cloudName : toRemove) {
                cloudNames.remove(cloudName);
            }
        }
    }
    if (cloudTemplates != null && !cloudTemplates.isEmpty()) {
        // Now walk the templates and verify.
        // Unlike the clouds, verified templates are removed from the list upon
        // verification (or left if they do not verify)
        synchronized (templatesLock) {
            List<String> toRemove = new ArrayList<String>();
            LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: verifying {0} template(s)", cloudTemplates.size());
            for (Map.Entry<String, String> entry : cloudTemplates.entrySet()) {
                String templateName = entry.getKey();
                String cloudName = entry.getValue();
                LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: verifying {0} in {1}", new Object[] { templateName, cloudName });
                AzureVMCloud cloud = getCloud(cloudName);
                // If the cloud is null, could mean that the cloud details changed
                // between the last time we ran this task
                if (cloud == null) {
                    LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: parent cloud not found for {0} in {1}", new Object[] { templateName, cloudName });
                    toRemove.add(templateName);
                    continue;
                }
                AzureVMAgentTemplate agentTemplate = cloud.getAzureAgentTemplate(templateName);
                // Template could have been removed since the last time we ran verification
                if (agentTemplate == null) {
                    LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: could not retrieve agent template named {0} in {1}", new Object[] { templateName, cloudName });
                    toRemove.add(templateName);
                    continue;
                }
                // Determine whether we need to verify the template
                if (agentTemplate.isTemplateVerified()) {
                    LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: template {0} in {1} already verified", new Object[] { templateName, cloudName });
                    // Good to go, nothing more to check here.  Add to removal list.
                    toRemove.add(templateName);
                    continue;
                }
                // The template is not yet verified.  Do so now
                try {
                    List<String> errors = agentTemplate.verifyTemplate();
                    if (errors.isEmpty()) {
                        LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: {0} verified succesfully", templateName);
                        // Verified, set the template to verified.
                        agentTemplate.setTemplateVerified(true);
                        // Reset the status details
                        agentTemplate.setTemplateStatusDetails("");
                    } else {
                        String details = String.join("\n", errors);
                        LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: {0} could not be verified:\n{1}", new Object[] { templateName, details });
                        // Set the status details to the set of messages
                        agentTemplate.setTemplateStatusDetails(details);
                    }
                } catch (Exception e) {
                    // Log, but ignore overall
                    LOGGER.log(Level.INFO, "AzureVMCloudVerificationTask: execute: got exception while verifying {0}:\n{1}", new Object[] { templateName, e.toString() });
                }
            }
            // Remove items as necessary
            for (String templateName : toRemove) {
                cloudTemplates.remove(templateName);
            }
        }
    }
    LOGGER.info("AzureVMCloudVerificationTask: execute: end");
}

[Buggy Hunk]
String details = String.join("\n", errors);

[Patch]
String details = StringUtils.join(errors, "\n");

[Demonstration 2]

[Buggy Method]
@Override
public void update(Observable o, Object arg) {
    String type = ((Bundle) arg).getString(OcrHandler.BUNDLE_TYPE);
    if ((!searchTerm.isEmpty()) && (type != null) && (type.equals(OcrHandler.DETECTOR_ACTION_STREAM))) {
        ArrayList<TextBlockParcel> texts = ((Bundle) arg).getParcelableArrayList(OcrHandler.BUNDLE_DETECTIONS);
        // find the term
        int found = -1;
        for (int i = 0; i < texts.size(); i++) {
            if (texts.get(i).getText().toLowerCase().contains(searchTerm)) {
                found = i;
            }
        }
        // gets the search term
        if (found != -1) {
            Toast.makeText(getActivity().getApplicationContext(), getResources().getString(R.string.toast_search_term_found_within_text, searchTerm, texts.get(found)), Toast.LENGTH_SHORT).show();
            ((MainActivity) getActivity()).vibrate(500);
            // reset analysing
            searchTerm = "";
            mCameraService.play(MediaActionSound.STOP_VIDEO_RECORDING);
            // get image and image config
            ImageConfigParcel config = ((Bundle) arg).getParcelable(OcrHandler.BUNDLE_IMG_CONFIG);
            byte[] image = ((Bundle) arg).getByteArray(OcrHandler.BUNDLE_IMG_DATA);
            // save an image
            if ((config != null) && (image != null)) {
                String snapshot = Constants.IMAGE_PATH + "/img-" + System.currentTimeMillis() + ".jpg";
                // saves the image asynchronously to the external storage
                new ImagePersistenceHelper(config.getFormat(), config.getRotation(), config.getWidth(), config.getHeight(), snapshot).execute(image);
                Toast.makeText(getActivity().getApplicationContext(), getResources().getString(R.string.toast_snapshot_saved_to, snapshot), Toast.LENGTH_SHORT).show();
                AudioService.getInstance().speak(getResources().getString(R.string.read_mode_snapshot_saved));
            }
            // gets the detected texts
            detectedTexts = texts;
            // show button
            mInflatedView.findViewById(R.id.btn_send_to_read).setEnabled(true);
        }
    }
}

[Buggy Hunk]
if (texts.get(i).getText().toLowerCase().contains(searchTerm)) { found = i; }

[Patch]
if (texts.get(i).getText().toLowerCase().contains(searchTerm.toLowerCase())) { found = i; }

[Demonstration 3]

[Buggy Method]
synchronized ProxyServer getProxyServer() {
    ProxyServer result = null;
    if (proxyServers.isEmpty()) {
        LOGGER.info("no proxy");
    } else {
        result = proxyServers.get(current++);
        if (current >= proxyServers.size()) {
            current = 0;
        }
    }
    return result;
}

[Buggy Hunk]
LOGGER.info("no proxy");

[Patch]
LOGGER.debug("no proxy");