[ 
https://issues.apache.org/jira/browse/IGNITE-6944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16260169#comment-16260169
 ] 

Edmond Tsang commented on IGNITE-6944:
--------------------------------------

[~agura] by breaking 
[IGNITE-6485|https://issues.apache.org/jira/browse/IGNITE-6485] do you mean it 
would break the test case testWriteReplace() under 
org.apache.ignite.internal.binary.BinaryMarshallerSelfTest.java?

if so, it appears it is an issue in the test case. 

testWriteReplace() try serialize and deserialize the TestObject:
{code:java}
    public void testWriteReplace() throws Exception {
        BinaryMarshaller marsh = binaryMarshaller(Collections.singleton(
            new BinaryTypeConfiguration(TestObject.class.getName())
        ));

        TestObject obj = new TestObject();

        BinaryObject po = marshal(obj, marsh);

        assertEquals(obj, po.deserialize());

        assertEquals(obj.val, ((BinaryObject)po.field("val")).deserialize());
    }
{code}

TestObject has variable val of type Intf:
{code:java}
    static class TestObject {
        /** Value. */
        Intf val = new IntfImpl();

        /** {@inheritDoc} */
        @Override public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;

            TestObject obj = (TestObject)o;

            return val.equals(obj.val);
        }
    }
{code}

IntfImpl extends Cls and implement Intf:
{code:java}
    static class IntfImpl extends Cls implements Intf {
        /** {@inheritDoc} */
        @Override public long value() {
            return longValue();
        }
    }
{code}

Method readResolve() from SerializationProxy return val from Cls object, 
however Cls doesn't implement IntfImpl which causes the issue:
{code:java}
    static class Cls implements Serializable {
        /** Value. */
        long val;

        /** */
        public long longValue() {
            return val;
        }

        /** {@inheritDoc} */
        @Override public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;

            Cls cls = (Cls)o;

            return val == cls.val;
        }

        /** */
        private Object writeReplace() {
            return new SerializationProxy(this);
        }

        /** */
        private static class SerializationProxy implements Serializable {
            /** Value. */
            private final long val;

            /** */
            SerializationProxy(Cls a) {
                val = a.longValue();
            }

            /** */
            private Object readResolve() {
                Cls a = new Cls();

                a.val = val;

                return a;
            }
        }
    }
{code}

Changing the readResolve method to return val from IntfImpl object can fix the 
issue:
{code:java}
            private Object readResolve() {
                IntfImpl a = new IntfImpl();

                a.val = val;

                return a;
            }
{code}






> Fail to execute task with immutable list string
> -----------------------------------------------
>
>                 Key: IGNITE-6944
>                 URL: https://issues.apache.org/jira/browse/IGNITE-6944
>             Project: Ignite
>          Issue Type: Bug
>          Components: binary
>    Affects Versions: 2.3
>            Reporter: Edmond Tsang
>         Attachments: BinaryMarshellerWithGuavaSelfTest.java, 
> TestClientWithGuava.java
>
>
> Exception occurs when executing task with immutable list of string due to not 
> able to find method readResolve/writeReplace for binary object.
> It appears this is caused by a side effect of Jira 
> https://issues.apache.org/jira/browse/IGNITE-6485 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to