[Demonstration 1]

[Buggy Method]
@Path("/validatecollaborativecontent/{idAnnotatedCollaborativeContentAnalysis:\\d+}/status")
@GET
public String getStatusCollaborativeContentVerifications(@PathParam("idAnnotatedCollaborativeContentAnalysis") String contentID) throws LpRestException {
    try {
        if (map.containsKey(Integer.valueOf(contentID))) {
            List<AbstractAnalysisClass> listanalysisInterface = map.get(Integer.valueOf(contentID));
            Integer progress = getProgress(listanalysisInterface);
            if (progress > 99)
                return "OK";
            else
                return "InProgess_" + progress + "%";
        }
        log.error("Element not found");
        return "ERROR";
    } catch (Exception e) {
        log.fatal("Fatal " + e.getMessage());
        return "FATAL ERROR";
    }
}

[Buggy Hunk]
log.error("Element not found");

[Patch]
log.error("Element not found: "+contentID+" map:"+map.keySet().toString());

[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]
private static Map<String, String[]> getUrlParams(String url) {
    Map<String, String[]> result = new HashMap<String, String[]>();
    try {
        String queryString = url;
        if (url.contains("?")) {
            queryString = url.substring(url.indexOf("?") + 1);
        }
        if (queryString.length() > 1) {
            String[] params = queryString.split("&");
            for (String a : params) {
                if (!a.isEmpty()) {
                    String[] param = a.split("=");
                    String key = URLDecoder.decode(param[1], "UTF-8");
                    String value = URLDecoder.decode(param[1], "UTF-8");
                    String[] values = (String[]) result.get(key);
                    if (values != null) {
                        List temp = Arrays.asList(values);
                        temp.add(value);
                        values = (String[]) temp.toArray(new String[0]);
                    } else {
                        values = new String[] { value };
                    }
                    result.put(key, values);
                }
            }
        }
    } catch (Exception e) {
    }
    return result;
}

[Buggy Hunk]
String key = URLDecoder.decode(param[1], "UTF-8");

[Patch]
String key = URLDecoder.decode(param[0], "UTF-8");