Il giorno 04/mag/2012, alle ore 17.04, René Mulder ha scritto:

> I've modified one file (the simplest i could find) to get rid of the bad 
> practice notification of sonar as an example. Is this a format that we want?
> 
> https://svn.apache.org/repos/asf/incubator/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ResourcesPanel.java

Hi René,
I am not sure that this approach is the right one: 

1. we have a lot of anonymous inner classes;
2. the usage of anonymous inner classes seems to be a suggested practice in 
wicket;
3. often (probably always) anonymous inner classes are used only by their 
enclosing class.

Probably we have to transform an anonymous inner class into a nested class if 
and only if this class could be used by some other classes but not just the 
enclosing one.

WDYT?

Regards,
F.

> On May 4, 2012, at 4:48 PM, René Mulder wrote:
> 
>> Hi All,
>> 
>> I've been going through the Sonar violations and found that we have 226 
>> major violations of the following type:
>> 
>> Bad practice - Serializable inner class
>> 
>> findbugs : SE_INNER_CLASS
>> This Serializable class is an inner class. Any attempt to serialize it will 
>> also serialize the associated outer instance. The outer instance is 
>> serializable, so this won't fail, but it might serialize a lot more data 
>> than intended. If possible, making the inner class a static inner class 
>> (also known as a nested class) should solve the problem.
>> 
>> 
>> 
>> As I see it, the way to solve this is to extract these classes and inject 
>> the fields that they currently use of the parent classes. The thing is, are 
>> these classes really ever serialized without their parent class being 
>> serialized as well? So is this indeed bad practice? And do we ever reuse 
>> these inner classes? It seems to me that they are very specific to the 
>> parent class. So basicly: should i solve this and how?
>> 
>> 
>> Regards,
>> René
>> 
>> 
> 

Reply via email to