[jboss-jira] [JBoss JIRA] Commented: (JGRP-753) cache object returned from Message.getObject() (deserialization occurs on every call)
Michael Newcomb (JIRA)
jira-events at lists.jboss.org
Mon May 12 09:27:21 EDT 2008
[ http://jira.jboss.com/jira/browse/JGRP-753?page=comments#action_12412460 ]
Michael Newcomb commented on JGRP-753:
--------------------------------------
The problem with not caching this object in the Message is the fact that you can get Message from several different sources.
For example, MessageDispatcher supports both a MessageListener and a RequestHandler. So, you can get a Message from two different sources:
MessageListener.receive(Message msg);
-and-
RequestHandler.handle(Message msg);
If both inspect the msg.getObject(), 2 deserializations have occurred.
If the value returned by getObject() is not cached by Message, it might be better to remove the get/setObject capability from Message.
We suffered from this because we had a custom dispatcher that inspected the msg.getObject() and then called super.handle(msg) if it wasn't for us. If it is not cached, I will have to rework (which is no big deal) our code to have a final RequestHandler.handle() that extracts the object and then calls some overridable method.
This still doesn't solve the problem where there are 2 distinct paths (MessageListener and RequestHandler) a message is passed to.
> cache object returned from Message.getObject() (deserialization occurs on every call)
> -------------------------------------------------------------------------------------
>
> Key: JGRP-753
> URL: http://jira.jboss.com/jira/browse/JGRP-753
> Project: JGroups
> Issue Type: Feature Request
> Affects Versions: 2.6.2
> Reporter: Michael Newcomb
> Assigned To: Bela Ban
> Fix For: 2.6.3, 2.7
>
>
> Proposed solution:
> 33 /** The payload */
> 34 private byte[] buf=null;
> 34.1 private Object obj;
> 291 final public Object getObject() {
> 291.1 if (obj == null) {
> 292 try {
> 293 obj = Util.objectFromByteBuffer(buf, offset, length);
> 294 }
> 295 catch(Exception ex) {
> 296 throw new IllegalArgumentException(ex);
> 297 }
> 297.1 }
> 297.2 return obj;
> 298 }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list