-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 All,
I'm interested in the history of the StandardSession.writeObjectData method. I've been looking at it lately because I'm interested in possibly (optionally) encrypting the sessions in the backend session store. But this isn't about encryption at all. The code for StandardSession.doWriteObject(ObjectOutputStream stream) looks like this: // Write the scalar instance variables (except Manager) stream.writeObject(Long.valueOf(creationTime)); stream.writeObject(Long.valueOf(lastAccessedTime)); stream.writeObject(Integer.valueOf(maxInactiveInterval)); stream.writeObject(Boolean.valueOf(isNew)); stream.writeObject(Boolean.valueOf(isValid)); stream.writeObject(Long.valueOf(thisAccessedTime)); Is there any reason we are writing object wrappers for these primitive members instead of just writing the primitives directly? It turns out that the byte stream is identical whether one uses objects or primitives, but the code is a little more complicated, generates objects when none are necessary, etc. Here is the doReadObject code: creationTime = ((Long) stream.readObject()).longValue(); lastAccessedTime = ((Long) stream.readObject()).longValue(); maxInactiveInterval = ((Integer) stream.readObject()).intValue() ; isNew = ((Boolean) stream.readObject()).booleanValue(); isValid = ((Boolean) stream.readObject()).booleanValue(); thisAccessedTime = ((Long) stream.readObject()).longValue(); If using primitives, it would be: creationTime = stream.readLong(); lastAccessedTime = stream.readLong(); maxInactiveInterval = stream.readInt(); isNew = stream.readBoolean(); isValid = stream.readBoolean(); thisAccessedTime = stream.readLong(); I don't believe there is any benefit to using objects over primitives in this case. If the stream doesn't contain the right object types in the right order, the operation will fail so they are providing any e.g. type-safety that you might get by casting to (Number) and then pulling long value (to convert an int -> long, possibly). I think the code is easier to read and will generate less temporary garbage if the wrapper objects are removed. I think the change will also remain interoperable between versions since the byte-stream is unchanged. Any objections to making this change? - -chris -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl69aFEACgkQHPApP6U8 pFiiGA/+OTShGMP1QvzP9rINT8hyrjhoiXTxCN6cfazQZ3Q8UUXAFA6514tLLkli 3FBfu6CWyAe1S8WvzgkeWg0UospfKjSi3pod/uVjF9Bo4JYyPAe39FV8k74Suotk HpQNbrrFMp7MeQowXdtns/ua8F+uo77JXTHrdc3eZIhBpfiyyyPQLaC73r/djMwf v/0iDF/SBAL98fTQsnTqeFVGJGBUkHS1Yvuhr1DQ+I6gpSRn+wUGlvUmrxaNF6J6 opYfBpU53L/2skjN7yC/DC5pnYbgRRzKdoNKzgrNbEbK9dyqEztr4N82+8VdIccj BJJA+7LqYDkVvrrTSCBL8hTlWr10P609rwX7t+/LHl0SzBVdsdiZurpBD/SRZXbQ nNU2n2DauAVUDUsKoLR/MvzpGVW3cNJNOqMX8mscA9RkLJwfWTnrohD7YFXtj6iv D03ekPpOBGSF1TX6JAjgDuciSPD2/Z9NV6wR1yKcfjm/rKkoAnv/orP/ccTsuXnq fggNFZQAmfp93QJFf2G3wntmR/3fCWjETVWT5CxyTxSdn/Zmj08P2lKiyRUriLd1 4kGnNxLSFgo/UWIgoFaPeITbkupmI9rGQq+LZM1UlnhoHxWj3vVOdCN/Zu+3OpLQ rFD5YTunZmHDBIcbtHbOmHeAGq7VU1BpvJ7V50jz9LW6OoX6GfQ= =vEuO -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org