commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tommaso Teofili <tommaso.teof...@gmail.com>
Subject Re: [DIGESTER-AT] annotations.utils.InMemoryLRUCache$1 is serializable but containing class is nit
Date Wed, 27 Jan 2010 17:25:34 GMT
Hi Sebb,
 I also noticed that but I think that making the container Serializable is
not useful neither wanted though I agree that it should be documented or
maybe refactored i.e. extracting the Serializable class in a
LRULinkedHashMap class extending LinkedHashMap wiith the specified method
and constructor.
Cheers,
Tommaso

2010/1/27 sebb <sebbaz@gmail.com>

> Findbugs reports the following error:
>
> >>>
> Bug: org.apache.commons.digester.annotations.utils.InMemoryLRUCache$1
> is serializable but also an inner class of a non-serializable class
> Pattern id: SE_BAD_FIELD_INNER_CLASS, type: Se, category: BAD_PRACTICE
>
> This Serializable class is an inner class of a non-serializable class.
> Thus, attempts to serialize it will also attempt to associate instance
> of the outer class with which it is associated, leading to a runtime
> error.
>
> If possible, making the inner class a static inner class should solve
> the problem. Making the outer class serializable might also work, but
> that would mean serializing an instance of the inner class would
> always also serialize the instance of the outer class, which it often
> not what you really want.
> <<<
>
> It's not possible to make the inner class static, however it should be
> possible to make the container Serializable. I'm not sure if that is
> wanted or not.
>
> If not, then I think the only solution is to document the fact that
> although the inner class is serializable, this is not intentional.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message