<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.7.4</li>
<li>Operating System version: macos  10.13.6</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<p dir="auto">add unit test in ProtostuffObjectOutputTest.class and failed:</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
    @Test
    public void testListObject() throws IOException, ClassNotFoundException {
        List&lt;SerializablePerson&gt; list = new ArrayList&lt;SerializablePerson&gt;();
        list.add(new SerializablePerson());
        list.add(new SerializablePerson());
        list.add(new SerializablePerson());
        SerializablePersonList personList = new SerializablePersonList(list);
        this.protostuffObjectOutput.writeObject(personList);
        this.flushToInput();

        SerializablePersonList serializedTime = protostuffObjectInput.readObject(SerializablePersonList.class);
        assertThat(serializedTime, is(personList));
    }

 private class SerializablePersonList implements Serializable {
        private static final long serialVersionUID = 1L;

        public List&lt;SerializablePerson&gt; personList;

        public SerializablePersonList() {}

        public SerializablePersonList(List&lt;SerializablePerson&gt; list) {
            this.personList = list;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;

            SerializablePersonList list = (SerializablePersonList) obj;
            if (list.personList == null &amp;&amp; this.personList == null)
                return true;
            if (list.personList == null || this.personList == null)
                return false;
            if (list.personList.size() != this.personList.size())
                return false;
            for (int i =0; i &lt; this.personList.size(); i++) {
                if (!this.personList.get(i).equals(list.personList.get(i)))
                    return false;
            }
            return true;
        }
    }
"><pre class="notranslate">    <span class="pl-c1">@</span><span class="pl-c1">Test</span>
    <span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-s1">testListObject</span>() <span class="pl-k">throws</span> <span class="pl-smi">IOException</span>, <span class="pl-s1">ClassNotFoundException</span> {
        <span class="pl-smi">List</span>&lt;<span class="pl-smi">SerializablePerson</span>&gt; <span class="pl-s1">list</span> = <span class="pl-k">new</span> <span class="pl-smi">ArrayList</span>&lt;<span class="pl-smi">SerializablePerson</span>&gt;();
        <span class="pl-s1">list</span>.<span class="pl-en">add</span>(<span class="pl-k">new</span> <span class="pl-smi">SerializablePerson</span>());
        <span class="pl-s1">list</span>.<span class="pl-en">add</span>(<span class="pl-k">new</span> <span class="pl-smi">SerializablePerson</span>());
        <span class="pl-s1">list</span>.<span class="pl-en">add</span>(<span class="pl-k">new</span> <span class="pl-smi">SerializablePerson</span>());
        <span class="pl-smi">SerializablePersonList</span> <span class="pl-s1">personList</span> = <span class="pl-k">new</span> <span class="pl-smi">SerializablePersonList</span>(<span class="pl-s1">list</span>);
        <span class="pl-smi">this</span>.<span class="pl-s1">protostuffObjectOutput</span>.<span class="pl-en">writeObject</span>(<span class="pl-s1">personList</span>);
        <span class="pl-smi">this</span>.<span class="pl-en">flushToInput</span>();

        <span class="pl-smi">SerializablePersonList</span> <span class="pl-s1">serializedTime</span> = <span class="pl-s1">protostuffObjectInput</span>.<span class="pl-en">readObject</span>(<span class="pl-smi">SerializablePersonList</span>.<span class="pl-k">class</span>);
        <span class="pl-en">assertThat</span>(<span class="pl-s1">serializedTime</span>, <span class="pl-en">is</span>(<span class="pl-s1">personList</span>));
    }

 <span class="pl-k">private</span> <span class="pl-k">class</span> <span class="pl-smi">SerializablePersonList</span> <span class="pl-k">implements</span> <span class="pl-smi">Serializable</span> {
        <span class="pl-k">private</span> <span class="pl-k">static</span> <span class="pl-k">final</span> <span class="pl-smi">long</span> <span class="pl-s1">serialVersionUID</span> = <span class="pl-c1">1L</span>;

        <span class="pl-k">public</span> <span class="pl-smi">List</span>&lt;<span class="pl-smi">SerializablePerson</span>&gt; <span class="pl-s1">personList</span>;

        <span class="pl-k">public</span> <span class="pl-smi">SerializablePersonList</span>() {}

        <span class="pl-k">public</span> <span class="pl-smi">SerializablePersonList</span>(<span class="pl-smi">List</span>&lt;<span class="pl-smi">SerializablePerson</span>&gt; <span class="pl-s1">list</span>) {
            <span class="pl-smi">this</span>.<span class="pl-s1">personList</span> = <span class="pl-s1">list</span>;
        }

        <span class="pl-c1">@</span><span class="pl-c1">Override</span>
        <span class="pl-k">public</span> <span class="pl-smi">boolean</span> <span class="pl-en">equals</span>(<span class="pl-smi">Object</span> <span class="pl-s1">obj</span>) {
            <span class="pl-k">if</span> (<span class="pl-smi">this</span> == <span class="pl-s1">obj</span>)
                <span class="pl-k">return</span> <span class="pl-c1">true</span>;
            <span class="pl-k">if</span> (<span class="pl-s1">obj</span> == <span class="pl-c1">null</span>)
                <span class="pl-k">return</span> <span class="pl-c1">false</span>;
            <span class="pl-k">if</span> (<span class="pl-en">getClass</span>() != <span class="pl-s1">obj</span>.<span class="pl-en">getClass</span>())
                <span class="pl-k">return</span> <span class="pl-c1">false</span>;

            <span class="pl-smi">SerializablePersonList</span> <span class="pl-s1">list</span> = (<span class="pl-smi">SerializablePersonList</span>) <span class="pl-s1">obj</span>;
            <span class="pl-k">if</span> (<span class="pl-s1">list</span>.<span class="pl-s1">personList</span> == <span class="pl-c1">null</span> &amp;&amp; <span class="pl-smi">this</span>.<span class="pl-s1">personList</span> == <span class="pl-c1">null</span>)
                <span class="pl-k">return</span> <span class="pl-c1">true</span>;
            <span class="pl-k">if</span> (<span class="pl-s1">list</span>.<span class="pl-s1">personList</span> == <span class="pl-c1">null</span> || <span class="pl-smi">this</span>.<span class="pl-s1">personList</span> == <span class="pl-c1">null</span>)
                <span class="pl-k">return</span> <span class="pl-c1">false</span>;
            <span class="pl-k">if</span> (<span class="pl-s1">list</span>.<span class="pl-s1">personList</span>.<span class="pl-en">size</span>() != <span class="pl-smi">this</span>.<span class="pl-s1">personList</span>.<span class="pl-en">size</span>())
                <span class="pl-k">return</span> <span class="pl-c1">false</span>;
            <span class="pl-k">for</span> (<span class="pl-smi">int</span> <span class="pl-s1">i</span> =<span class="pl-c1">0</span>; <span class="pl-s1">i</span> &lt; <span class="pl-smi">this</span>.<span class="pl-s1">personList</span>.<span class="pl-en">size</span>(); <span class="pl-s1">i</span>++) {
                <span class="pl-k">if</span> (!<span class="pl-smi">this</span>.<span class="pl-s1">personList</span>.<span class="pl-en">get</span>(<span class="pl-s1">i</span>).<span class="pl-en">equals</span>(<span class="pl-s1">list</span>.<span class="pl-s1">personList</span>.<span class="pl-en">get</span>(<span class="pl-s1">i</span>)))
                    <span class="pl-k">return</span> <span class="pl-c1">false</span>;
            }
            <span class="pl-k">return</span> <span class="pl-c1">true</span>;
        }
    }</pre></div>
<p dir="auto">This is one case,  and I have found the reason and raised a pr to fix it,  But there is another stackoverflow still exist.</p>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">What do you expected from the above steps？</p>
<p dir="auto">test success</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?</p>
<p dir="auto">test failed</p>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Just put your stack trace here!"><pre class="notranslate"><code class="notranslate">Just put your stack trace here!
</code></pre></div>
<p dir="auto">I find that there are much duplicate code in the method afterPropertiesSet of ServiceBean and ReferenceBean. Can we move them to their common super class ?</p>