<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/incubator-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/incubator-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.0</li>
<li>Operating System version: macOS Sierra 10.12</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<p dir="auto">We are going to support Google PB serialization with Hessian2 as delegate to write buffer to channel. But, the readInputStream cannot parse the tag from the BytesOutputStream.</p>
<ol dir="auto">
<li>write stream direct to Hessian2Output BytesOutputStream.</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="protected AbstractProtobufObjectOutput(OutputStream os) {
  this.delegate = new Hessian2ObjectOutput(os);
}

private void writeStream(Object obj) throws IOException {
  Hessian2ObjectOutput hessian2ObjectOutput = (Hessian2ObjectOutput) delegate;
  OutputStream outputStream = hessian2ObjectOutput.getOutput().getBytesOutputStream();
  protobufUtil.serializeWithProtobuf(obj, outputStream);
}"><pre class="notranslate"><code class="notranslate">protected AbstractProtobufObjectOutput(OutputStream os) {
  this.delegate = new Hessian2ObjectOutput(os);
}

private void writeStream(Object obj) throws IOException {
  Hessian2ObjectOutput hessian2ObjectOutput = (Hessian2ObjectOutput) delegate;
  OutputStream outputStream = hessian2ObjectOutput.getOutput().getBytesOutputStream();
  protobufUtil.serializeWithProtobuf(obj, outputStream);
}
</code></pre></div>
<ol start="2" dir="auto">
<li>read the stream from the Hessian2Input readInputStream.</li>
</ol>
<p dir="auto">protected AbstractProtobufObjectInput(InputStream is) {<br>
this.delegate = new Hessian2ObjectInput(is);<br>
}</p>
<p dir="auto"> T deserializeWithStream(Class clazz)<br>
throws IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {<br>
Hessian2ObjectInput input = (Hessian2ObjectInput) delegate;<br>
InputStream inputStream = input.getOutput().readInputStream();<br>
return deserializeWithProtobuf(inputStream, clazz);<br>
}</p>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">Google Protobuf should be able to read inputStream from Hessian2Input readInputStream.</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">The tag value should be 'B' or 'b', actually it's not.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@Override
    public InputStream readInputStream() throws IOException {
    int tag = read();

    switch (tag) {
       case 'B':
       case 'b':
            _isLastChunk = tag == 'B';
            _chunkLength = (read() &lt;&lt; 8) + read();
            break;

        default:
            throw expect(&quot;binary&quot;, tag);
   }

    return new ReadInputStream();
}"><pre class="notranslate"><code class="notranslate">@Override
    public InputStream readInputStream() throws IOException {
    int tag = read();

    switch (tag) {
       case 'B':
       case 'b':
            _isLastChunk = tag == 'B';
            _chunkLength = (read() &lt;&lt; 8) + read();
            break;

        default:
            throw expect("binary", tag);
   }

    return new ReadInputStream();
}
</code></pre></div>
<p dir="auto">From the Hessian2Output's BytesOutputStream, we are able to see write 'A' for continue, but 'B' for close.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@Override
public void write(byte[] buffer, int offset, int length)
        throws IOException {
    while (length &gt; 0) {
        int sublen = SIZE - _offset;

        if (length &lt; sublen)
            sublen = length;

        if (sublen &gt; 0) {
            System.arraycopy(buffer, offset, _buffer, _offset, sublen);
            _offset += sublen;
        }

        length -= sublen;
        offset += sublen;

        if (SIZE &lt;= _offset) {
            int chunkLength = (_offset - _startOffset) - 3;

            _buffer[_startOffset] = (byte) BC_BINARY_CHUNK;
            _buffer[_startOffset + 1] = (byte) (chunkLength &gt;&gt; 8);
            _buffer[_startOffset + 2] = (byte) (chunkLength);

            Hessian2Output.this.flush();

            _startOffset = _offset;
            _offset += 3;
        }
    }
}

@Override
public void close()
        throws IOException {
    int startOffset = _startOffset;
    _startOffset = -1;

    if (startOffset &lt; 0)
        return;

    int length = (_offset - startOffset) - 3;

    _buffer[startOffset] = (byte) 'B';
    _buffer[startOffset + 1] = (byte) (length &gt;&gt; 8);
    _buffer[startOffset + 2] = (byte) (length);

    Hessian2Output.this.flush();
}"><pre class="notranslate"><code class="notranslate">@Override
public void write(byte[] buffer, int offset, int length)
        throws IOException {
    while (length &gt; 0) {
        int sublen = SIZE - _offset;

        if (length &lt; sublen)
            sublen = length;

        if (sublen &gt; 0) {
            System.arraycopy(buffer, offset, _buffer, _offset, sublen);
            _offset += sublen;
        }

        length -= sublen;
        offset += sublen;

        if (SIZE &lt;= _offset) {
            int chunkLength = (_offset - _startOffset) - 3;

            _buffer[_startOffset] = (byte) BC_BINARY_CHUNK;
            _buffer[_startOffset + 1] = (byte) (chunkLength &gt;&gt; 8);
            _buffer[_startOffset + 2] = (byte) (chunkLength);

            Hessian2Output.this.flush();

            _startOffset = _offset;
            _offset += 3;
        }
    }
}

@Override
public void close()
        throws IOException {
    int startOffset = _startOffset;
    _startOffset = -1;

    if (startOffset &lt; 0)
        return;

    int length = (_offset - startOffset) - 3;

    _buffer[startOffset] = (byte) 'B';
    _buffer[startOffset + 1] = (byte) (length &gt;&gt; 8);
    _buffer[startOffset + 2] = (byte) (length);

    Hessian2Output.this.flush();
}
</code></pre></div>
<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>
<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.3</li>
<li>Operating System version: Mac OS</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<p dir="auto">1.RouterChain#buildChain(URL)<br>
2.RouterChain#initWithRouters()<br>
3.RouterChain#sort()</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">ServiceRouter is High priority than AppRouter</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">AppRouter is High priority than ServiceRouter</p>
<h3 dir="auto">Cause by</h3>
<p dir="auto">the code was on ListenableRouter 94~96 line</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public abstract class ListenableRouter extends AbstractRouter implements ConfigurationListener {    
    ......
    ......
    @Override
    public int getPriority() {
        return DEFAULT_PRIORITY;
    }"><pre class="notranslate"><code class="notranslate">public abstract class ListenableRouter extends AbstractRouter implements ConfigurationListener {    
    ......
    ......
    @Override
    public int getPriority() {
        return DEFAULT_PRIORITY;
    }
</code></pre></div>
<h3 dir="auto">Resolve</h3>
<p dir="auto">i think can like this：</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="public abstract class ListenableRouter extends AbstractRouter implements ConfigurationListener {    
    ......
    ......
    @Override
    public int getPriority() {
        return priority;
    }"><pre class="notranslate"><code class="notranslate">public abstract class ListenableRouter extends AbstractRouter implements ConfigurationListener {    
    ......
    ......
    @Override
    public int getPriority() {
        return priority;
    }
</code></pre></div>