[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2048) object references are not shared when deserialized

Mark Proctor (JIRA) jira-events at lists.jboss.org
Wed May 13 17:46:46 EDT 2009


    [ https://jira.jboss.org/jira/browse/JBRULES-2048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12467384#action_12467384 ] 

Mark Proctor commented on JBRULES-2048:
---------------------------------------

Not sure how to fix this at the moment. The reason is because we create an internal stream handler, that uses the provided stream. The process of doing this resets the handles[] table.

public class MarshallerWriteContext extends ObjectOutputStream {
    public MarshallerWriteContext(OutputStream stream,
                                  InternalRuleBase ruleBase,
                                  InternalWorkingMemory wm,
                                  Map<Integer, BaseNode> sinks,
                                  ObjectMarshallingStrategyStore resolverStrategyFactory,
                                  boolean marshalProcessInstances,
                                  boolean marshalWorkItems) throws IOException {
        super( stream );
        .......

That constructor does the following:
    public ObjectOutputStream(OutputStream out) throws IOException {
	verifySubclass();
	bout = new BlockDataOutputStream(out);
	handles = new HandleTable(10, (float) 3.00);

Thus the handles information is lost. Multi object references from inside the engine should be fine.


> object references are not shared when deserialized
> --------------------------------------------------
>
>                 Key: JBRULES-2048
>                 URL: https://jira.jboss.org/jira/browse/JBRULES-2048
>             Project: JBoss Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-compiler (expert)
>    Affects Versions: 5.0.0.CR1
>         Environment: 1.6.0_10
>            Reporter: Michal Bali
>            Assignee: Mark Proctor
>         Attachments: patch to rev 25427.txt
>
>
> Hi,
> The java.io.ObjectOutputStream API specifies that: "Multiple references to a single object are encoded using a reference sharing mechanism so that graphs of objects can be restored to the same shape as when the original was written. "
> Let's say that a knowledge session contains one fact. We serialize the knowledge session and the fact into one output stream. Then deserialize the session and the fact. The object references will be different. In my opinion this is a bug.
> Attached is a unit test to show this.
> Example use case:
> This can happen for example if the stateful knowledge session is stored within a HTTP servlet session. The HTTP servlet session can contain other objects that are part of the stateful knowledge session. When the HTTP servlet session is serialized and deserialized the object references will be different and it is for example no longer possible to do session.getFactHandleByIdentity(...).
> Please note that this issue might be fixed by fixing JBRULES-1925.
> Thank you.
> Best Regards,
> Michal

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list