commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Carman <>
Subject Re: svn commit: r989199 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/ test/java/org/apache/commons/lang3/
Date Thu, 26 Aug 2010 10:29:18 GMT
On Thu, Aug 26, 2010 at 5:04 AM, Henri Yandell <> wrote:
> I wonder if this could be a findbugs/checkstyle/pmd rule?

Why use findbugs for something like this when it's completely obvious
why it's okay?  When you serialize an object and then deserialize it,
you can be pretty sure you're going to get back the same type of
object.  Complaining about this particular piece of code it just plain
nitpicking, IMHO.

I would argue that the deserialize() method should be genericized as such:

public static <T extends Serializable> T deserialize(byte[] bytes);

This way, you could do:

Person p = SerializableUtils.deserialize(bytes);

No casting!  Now, if the bytes don't represent a Person object, then
you'll get a ClassCastException, but that's exactly the same thing
that would happen if you did this (with the current API):

Person p = (Person)SerializableUtils.deserialize(bytes);

So, we make it easier to use the API by avoiding a cast.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message