FP in S2441: Make "Map" and its parameters serializable or don't store it in the session?

Getting S2441 issue when storing a HashMap in the session. Based on SONARJAVA-1810 I believe this is a false positive, but wanted to check before opening a bug.

Here is a code sample to replicate the problem:

public void myFunction(HttpServletRequest request) {
        HttpSession session = request.getSession();
	
        Map<String, String> map = new HashMap<>();
        session.setAttribute("test with map", map); // false positive
	
        HashMap<String, String> hashmap = new HashMap<>();
        session.setAttribute("test with hashmap", hashmap); // no error
	
        List<String> list = new ArrayList<>(); 
    	session.setAttribute("test with list", list); // no error
    
        Set<String> set = new HashSet<>(); 
    	session.setAttribute("test with set", set); // no error
}
  • SonarQube Data Center Edition Version 7.7 (build 23042) and SonarLint for Eclipse 4.1.0.201901311043

Hi,

Thanks for reporting, I’ve created a ticket to fix this false positive.