[Demonstration 1]

[Buggy Method]
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_general);
    Preference intBase2 = (Preference) findPreference("int_base2");
    intBase2.setDefaultValue(Integer.toString(MainActivity.mDevice.diagTranscapIntDur()));
    Preference intBase59 = (Preference) findPreference("int_base59");
    intBase59.setDefaultValue(Integer.toString(MainActivity.mDevice.diagHybridIntDur()));
    Preference stretches = (Preference) findPreference("stretches");
    stretches.setDefaultValue(Integer.toString(MainActivity.mDevice.diagGearCount() + 1));
    Preference bwBase = (Preference) findPreference("bw_base");
    bwBase.setDefaultValue(Integer.toString(MainActivity.getC95FilterBwBurstLen()));
    PreferenceManager.setDefaultValues(getActivity(), R.xml.pref_general, false);
    userPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
    SharedPreferences.Editor editor = userPref.edit();
    editor.putString("int_base2", Integer.toString(MainActivity.mDevice.diagTranscapIntDur()));
    editor.putString("int_base59", Integer.toString(MainActivity.mDevice.diagHybridIntDur()));
    editor.putString("bw_base", Integer.toString(MainActivity.getC95FilterBwBurstLen()));
    editor.commit();
    if (MainActivity.mDevice.diagHasHybridBaselineControl() != 1) {
        intBase59.setEnabled(false);
        stretches.setEnabled(false);
    }
    setSummary();
}

[Buggy Hunk]
stretches.setDefaultValue(Integer.toString(MainActivity.mDevice.diagGearCount()+1));

[Patch]
stretches.setDefaultValue("1");

[Demonstration 2]

[Buggy Method]
@Path("/RNA/{c}")
@GET
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Reads rna sequence and generates HELMNotation", httpMethod = "GET", response = Response.class, responseContainer = "JSON")
@ApiResponses(value = { @ApiResponse(code = 200, message = "HELMNotation was successfully generated"), @ApiResponse(code = 400, message = "Error in rna sequence input") })
public Response generateHELMRNA(@ApiParam(value = "rna", required = true) @PathParam("c") String rna) throws ChemistryException {
    WebService webservice = new WebService();
    JSONObject json = new JSONObject();
    try {
        String result = webservice.readRNA(rna);
        json.put("HELMNotation", result);
        return Response.status(Response.Status.OK).entity(json.toString()).build();
    } catch (FastaFormatException | NotationException | IOException | JDOMException e) {
        json.put("ErrorMessage", e.getMessage());
        json.put("ErrorClass", e.getClass());
        return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
    }
}

[Buggy Hunk]
} catch (FastaFormatException | NotationException | IOException | JDOMException e) {

[Patch]
} catch (Exception e) {

[Demonstration 3]

[Buggy Method]
public static void addCartridgeGroup(CartridgeGroupBean serviceGroupDefinition, String cartridgeGroupUuid, int tenantId) throws InvalidCartridgeGroupDefinitionException, ServiceGroupDefinitionException, RestAPIException, CloudControllerServiceCartridgeNotFoundExceptionException, AutoscalerServiceInvalidServiceGroupExceptionException {
    if (serviceGroupDefinition == null) {
        throw new RuntimeException("Cartridge group definition is null");
    }
    List<String> cartridgeTypes = new ArrayList<String>();
    String[] cartridgeUuids;
    List<String> groupNames;
    String[] cartridgeGroupNames;
    if (log.isDebugEnabled()) {
        log.debug(String.format("Checking cartridges in cartridge group [tenant-id] %d [cartridge-group-uuid] %s " + "[cartridge-group-name] %s", tenantId, cartridgeGroupUuid, serviceGroupDefinition.getName()));
    }
    ServiceGroup serviceGroup = ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(serviceGroupDefinition, UUID.randomUUID().toString(), tenantId);
    try {
        findCartridgesInGroupBean(serviceGroup, cartridgeTypes);
    } catch (RemoteException e) {
        throw new RestAPIException(e.getMessage());
    }
    //validate the group definition to check if cartridges duplicate in any groups defined
    validateCartridgeDuplicationInGroupDefinition(serviceGroupDefinition);
    //validate the group definition to check if groups duplicate in any groups and
    //validate the group definition to check for cyclic group behaviour
    try {
        validateGroupDuplicationInGroupDefinition(serviceGroupDefinition);
    } catch (RemoteException e) {
        String message = String.format("Error while validating group duplications in cartridge group: [tenant-id]" + " %d [cartridge-group-uuid] %s [cartridge-group-name] %s", tenantId, cartridgeGroupUuid, serviceGroupDefinition.getName());
        log.error(message, e);
        throw new RestAPIException(message, e);
    }
    cartridgeUuids = new String[cartridgeTypes.size()];
    int j = 0;
    for (String cartridgeUuid : cartridgeTypes) {
        cartridgeUuids[j] = cartridgeUuid;
        j++;
    }
    // if any sub groups are specified in the group, they should be already deployed
    if (serviceGroupDefinition.getGroups() != null) {
        if (log.isDebugEnabled()) {
            log.debug(String.format("checking subGroups in cartridge group: [tenant-id] %d [cartridge-group-uuid]" + " %s [cartridge-group-name] %s", tenantId, cartridgeGroupUuid, serviceGroupDefinition.getName()));
        }
        List<CartridgeGroupBean> groupDefinitions = serviceGroupDefinition.getGroups();
        groupNames = new ArrayList<String>();
        cartridgeGroupNames = new String[groupDefinitions.size()];
        int i = 0;
        for (CartridgeGroupBean groupList : groupDefinitions) {
            groupNames.add(groupList.getName());
            cartridgeGroupNames[i] = groupList.getName();
            i++;
        }
        Set<String> duplicates = findDuplicates(groupNames);
        if (duplicates.size() > 0) {
            StringBuilder duplicatesOutput = new StringBuilder();
            for (String dup : duplicates) {
                duplicatesOutput.append(dup).append(" ");
            }
            if (log.isDebugEnabled()) {
                log.debug("duplicate sub-groups defined: " + duplicatesOutput.toString());
            }
            throw new InvalidCartridgeGroupDefinitionException("Invalid cartridge group definition, duplicate " + "sub-groups defined:" + duplicatesOutput.toString());
        }
    }
    AutoscalerServiceClient asServiceClient = getAutoscalerServiceClient();
    try {
        asServiceClient.addServiceGroup(serviceGroup);
        // Add cartridge group elements to SM cache - done after service group has been added
        StratosManagerServiceClient smServiceClient = getStratosManagerServiceClient();
        smServiceClient.addUsedCartridgesInCartridgeGroups(serviceGroup.getUuid(), cartridgeUuids);
    } catch (RemoteException e) {
        String message = String.format("Could not add the cartridge group: [cartridge-group-name] %s ", serviceGroupDefinition.getName());
        log.error(message, e);
        throw new RestAPIException(message, e);
    }
}

[Buggy Hunk]
(serviceGroupDefinition,UUID.randomUUID().toString(), tenantId);

[Patch]
(serviceGroupDefinition, cartridgeGroupUuid, tenantId);