Hello everybody,
I think the Rule squid:S1948 should not raise an issue for the following example:
public class MyTestSerializableFields implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Map with Maps with serializable datatypes
*/
// squid:S1948 is NOT ok(!) because it's private
// squid:S1948 - Fields in a "Serializable" class should either be transient or serializable"
private final Map<String, Map<Locale, String>> finalPrivateMapWithMap = new HashMap<String, Map<Locale, String>>();
/**
* Map with Lists with serializable datatype
*/
// squid:S1948 is NOT ok(!) because it's private
// squid:S1948 - Fields in a "Serializable" class should either be transient or serializable"
private final Map<String, List<String>> finalPrivateMapWithList = new HashMap<String, List<String>>();
public Map<String, Map<Locale, String>> getFinalPrivateMapWithMap() {
return finalPrivateMapWithMap;
}
public Map<String, List<String>> getFinalPrivateMapWithList() {
return finalPrivateMapWithList;
}
}
All types are serializable and especially for Collections/Maps the fields are private. No 'setters' are present to set any unserializable data.
Is it possible to remove that false positive from that rule?
Our Setup is SonarQube Version 5.3 and Java 3.12. Also tested wit SonarQube 5.3 and Java 3.13.1.
Regards,
Guido