[Demonstration 1]

[Buggy Method]
private Set<String> enableComplementaryModules(String collection) {
    Set<String> returnList = new HashSet<>();
    List<String> enabledModuleIds = new ArrayList<>();
    for (InstallableModule enabledModule : getEnabledModules(collection)) {
        enabledModuleIds.add(enabledModule.getId());
    }
    for (InstallableModule complementaryModule : getComplementaryModules()) {
        if (enabledModuleIds.containsAll(getDependencies(complementaryModule))) {
            if (!isInstalled(complementaryModule)) {
                returnList.addAll(installValidModuleAndGetInvalidOnes(complementaryModule, appLayerFactory.getModelLayerFactory().getCollectionsListManager()));
            }
            if (!isModuleEnabled(collection, complementaryModule)) {
                returnList.addAll(enableValidModuleAndGetInvalidOnes(collection, complementaryModule));
            }
        }
    }
    return returnList;
}

[Buggy Hunk]
private Set<String> enableComplementaryModules(String collection) {

[Patch]
public Set<String> enableComplementaryModules(String collection) {

[Demonstration 2]

[Buggy Method]
@RequestMapping(value = "/authService", method = RequestMethod.POST)
@ApiOperation(value = "authService", notes = "Used to Authenticate User", position = 0, consumes = "application/json")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Session created successfully") })
public Map<String, Object> createSession(@RequestBody UsernamePasswordToken token, HttpServletRequest request, BindingResult error) {
    UserForm userForm = new UserForm();
    Map<String, Object> authMap = new HashMap<>();
    boolean superAdminUser = false;
    boolean recapUser = false;
    Map<Integer, String> permissionMap = null;
    try {
        if (token == null) {
            authMap.put(UserManagement.USER_AUTHENTICATION, false);
            throw new AuthenticationException("User Name Password token is empty");
        }
        String[] values = UserManagement.userAndInstitution(token.getUsername());
        if (values != null) {
            userForm.setUsername(values[0]);
            userForm.setInstitution(Integer.valueOf(values[1]));
            userForm.setPassword(String.valueOf(token.getPassword()));
            loginValidator.validate(userForm, error);
        }
        if (error.hasErrors()) {
            logger.debug("Login Screen validation failed");
            authMap.put("authentication", false);
            throw new AuthenticationException("User Name Password token validation fails");
        }
        Subject subject = SecurityUtils.getSubject();
        subject.login(token);
        if (!subject.isAuthenticated()) {
            throw new AuthenticationException("Subject Authtentication Failed");
        }
        authorizationService.setSubject(token, subject);
        permissionMap = userService.getPermissions();
        getPermissionsForUI(subject, authMap, permissionMap);
        authMap.put(UserManagement.USER_AUTHENTICATION, true);
        authMap.put("userName", userForm.getUsername());
        authMap.put(UserManagement.USER_INSTITUTION, userForm.getInstitution());
        authMap.put(UserManagement.USER_ID, subject.getPrincipal());
        superAdminUser = UserManagement.SUPER_ADMIN.getIntegerValues() == (Integer) subject.getPrincipal() ? true : false;
        recapUser = subject.isPermitted(permissionMap.get(UserManagement.BARCODE_RESTRICTED.getPermissionId()));
        authMap.put(UserManagement.SUPER_ADMIN_USER, superAdminUser);
        authMap.put(UserManagement.ReCAP_USER, recapUser);
        Collections.unmodifiableMap(authMap);
        Session session = subject.getSession();
        session.setAttribute(UserManagement.PERMISSION_MAP, permissionMap);
        session.setAttribute(UserManagement.USER_ID, subject.getPrincipal());
    } catch (AuthenticationException e) {
        logger.debug("Authentication exception");
        logger.error("Exception in authentication : ", e);
        authMap.put(UserManagement.USER_AUTHENTICATION, false);
        authMap.put(UserManagement.USER_AUTH_ERRORMSG, e.getMessage());
    } catch (Exception e) {
        logger.error("Exception occured in authentication : " + e);
        authMap.put(UserManagement.USER_AUTHENTICATION, false);
        authMap.put(UserManagement.USER_AUTH_ERRORMSG, e.getMessage());
    }
    return authMap;
}

[Buggy Hunk]
logger.error("Exception occured in authentication : " + e);

[Patch]
logger.error("Exception occured in authentication : ",e);

[Demonstration 3]

[Buggy Method]
protected void onCreateWithFragment(Bundle savedInstanceState, int layoutId) {
    setContentView(layoutId);
    if (isNeedLoadingFragmentMain(savedInstanceState, fragmentId)) {
        fragment.setArguments(getIntent().getExtras());
        getSupportFragmentManager().beginTransaction().add(fragmentId, fragment).commit();
    }
}

[Buggy Hunk]
getSupportFragmentManager().beginTransaction().

[Patch]
getFragmentManager().beginTransaction().