Shahzeb
Shahzeb

Reputation: 4785

Findbugs non-transient non-serializable instance field

While running the code through FindBugs to pick up smelly bits I am getting
Bug: Class com.MyClass defines non-transient non-serializable instance field someSet Pattern id: SE_BAD_FIELD, type: Se, category: BAD_PRACTICE
I know set does not implement serialization but HashSet does and thats why it is being initialized then and there .I thought this was the good practice :( but apparently not

public class Myclass extends 
{ 
   @Transient
   private Set<String> someSet = new HashSet<String>();

        ...........
}

Any help would be great . Low level warning but would love to know why ?

Upvotes: 4

Views: 7174

Answers (1)

MeBigFatGuy
MeBigFatGuy

Reputation: 28598

Unfortunately, FindBugs isn't smart enough to recognize that the field that is defined as Set is actually a HashSet. It's a shortcoming of findbugs. You should add an issue here http://sourceforge.net/tracker/?group_id=96405&atid=614693

Upvotes: 4

Related Questions