<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> 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"> 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: win10</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>dubbo client is web project deployed in tomcat，and start up successfull。</li>
<li>when i call _ roleInterface.getRole(new RoleDTO());_</li>
<li>an exception raised ，here my code and stack trace followed，</li>
</ol>
<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>
<h3 dir="auto">Actual Result</h3>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="public interface RoleInterface {

	public RoleDTO getRole(long id);
	
	public RoleDTO getRole(RoleDTO dto);
	
}


public class RoleDTO implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long id;
	private String code;
	private String name;
	private long parentId;
	private long orgId;
	private int type;
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getParentId() {
		return parentId;
	}

	public void setParentId(long parentId) {
		this.parentId = parentId;
	}

	public long getOrgId() {
		return orgId;
	}

	public void setOrgId(long orgId) {
		this.orgId = orgId;
	}

}


@Service
public class RoleServiceImpl implements RoleInterface {

	@Override
	public RoleDTO getRole(long id) {
		
		String token = RpcContext.getContext().getAttachment(&quot;token&quot;);
		RoleDTO dto = new RoleDTO();
		
		dto.setId(id);
		dto.setName(&quot;test&quot;);
		return dto;
	}

	@Override
	public RoleDTO getRole(RoleDTO dto) {
		// TODO Auto-generated method stub
		return null;
	}

}

@Reference(url=&quot;dubbo://192.168.12.129:20812&quot;,check=false)
	public RoleInterface roleInterface;
	public Object getRole(long id) {
 		return roleInterface.getRole(new RoleDTO());
	}"><pre class="notranslate"><span class="pl-k">public</span> <span class="pl-k">interface</span> <span class="pl-smi">RoleInterface</span> {

	<span class="pl-k">public</span> <span class="pl-smi">RoleDTO</span> <span class="pl-en">getRole</span>(<span class="pl-smi">long</span> <span class="pl-s1">id</span>);
	
	<span class="pl-k">public</span> <span class="pl-smi">RoleDTO</span> <span class="pl-en">getRole</span>(<span class="pl-smi">RoleDTO</span> <span class="pl-s1">dto</span>);
	
}


<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">RoleDTO</span> <span class="pl-k">implements</span> <span class="pl-smi">Serializable</span> {

	<span class="pl-c">/**</span>
<span class="pl-c">	 * </span>
<span class="pl-c">	 */</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">private</span> <span class="pl-smi">long</span> <span class="pl-s1">id</span>;
	<span class="pl-k">private</span> <span class="pl-smi">String</span> <span class="pl-s1">code</span>;
	<span class="pl-k">private</span> <span class="pl-smi">String</span> <span class="pl-s1">name</span>;
	<span class="pl-k">private</span> <span class="pl-smi">long</span> <span class="pl-s1">parentId</span>;
	<span class="pl-k">private</span> <span class="pl-smi">long</span> <span class="pl-s1">orgId</span>;
	<span class="pl-k">private</span> <span class="pl-smi">int</span> <span class="pl-s1">type</span>;
	
	<span class="pl-k">public</span> <span class="pl-smi">String</span> <span class="pl-en">getCode</span>() {
		<span class="pl-k">return</span> <span class="pl-s1">code</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">setCode</span>(<span class="pl-smi">String</span> <span class="pl-s1">code</span>) {
		<span class="pl-smi">this</span>.<span class="pl-s1">code</span> = <span class="pl-s1">code</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">int</span> <span class="pl-en">getType</span>() {
		<span class="pl-k">return</span> <span class="pl-s1">type</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">setType</span>(<span class="pl-smi">int</span> <span class="pl-s1">type</span>) {
		<span class="pl-smi">this</span>.<span class="pl-s1">type</span> = <span class="pl-s1">type</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">long</span> <span class="pl-en">getId</span>() {
		<span class="pl-k">return</span> <span class="pl-s1">id</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">setId</span>(<span class="pl-smi">long</span> <span class="pl-s1">id</span>) {
		<span class="pl-smi">this</span>.<span class="pl-s1">id</span> = <span class="pl-s1">id</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">String</span> <span class="pl-en">getName</span>() {
		<span class="pl-k">return</span> <span class="pl-s1">name</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">setName</span>(<span class="pl-smi">String</span> <span class="pl-s1">name</span>) {
		<span class="pl-smi">this</span>.<span class="pl-s1">name</span> = <span class="pl-s1">name</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">long</span> <span class="pl-en">getParentId</span>() {
		<span class="pl-k">return</span> <span class="pl-s1">parentId</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">setParentId</span>(<span class="pl-smi">long</span> <span class="pl-s1">parentId</span>) {
		<span class="pl-smi">this</span>.<span class="pl-s1">parentId</span> = <span class="pl-s1">parentId</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">long</span> <span class="pl-en">getOrgId</span>() {
		<span class="pl-k">return</span> <span class="pl-s1">orgId</span>;
	}

	<span class="pl-k">public</span> <span class="pl-smi">void</span> <span class="pl-en">setOrgId</span>(<span class="pl-smi">long</span> <span class="pl-s1">orgId</span>) {
		<span class="pl-smi">this</span>.<span class="pl-s1">orgId</span> = <span class="pl-s1">orgId</span>;
	}

}


<span class="pl-c1">@</span><span class="pl-c1">Service</span>
<span class="pl-k">public</span> <span class="pl-k">class</span> <span class="pl-smi">RoleServiceImpl</span> <span class="pl-k">implements</span> <span class="pl-smi">RoleInterface</span> {

	<span class="pl-c1">@</span><span class="pl-c1">Override</span>
	<span class="pl-k">public</span> <span class="pl-smi">RoleDTO</span> <span class="pl-en">getRole</span>(<span class="pl-smi">long</span> <span class="pl-s1">id</span>) {
		
		<span class="pl-smi">String</span> <span class="pl-s1">token</span> = <span class="pl-smi">RpcContext</span>.<span class="pl-en">getContext</span>().<span class="pl-en">getAttachment</span>(<span class="pl-s">"token"</span>);
		<span class="pl-smi">RoleDTO</span> <span class="pl-s1">dto</span> = <span class="pl-k">new</span> <span class="pl-smi">RoleDTO</span>();
		
		<span class="pl-s1">dto</span>.<span class="pl-en">setId</span>(<span class="pl-s1">id</span>);
		<span class="pl-s1">dto</span>.<span class="pl-en">setName</span>(<span class="pl-s">"test"</span>);
		<span class="pl-k">return</span> <span class="pl-s1">dto</span>;
	}

	<span class="pl-c1">@</span><span class="pl-c1">Override</span>
	<span class="pl-k">public</span> <span class="pl-smi">RoleDTO</span> <span class="pl-en">getRole</span>(<span class="pl-smi">RoleDTO</span> <span class="pl-s1">dto</span>) {
		<span class="pl-c">// TODO Auto-generated method stub</span>
		<span class="pl-k">return</span> <span class="pl-c1">null</span>;
	}

}

<span class="pl-c1">@</span><span class="pl-c1">Reference</span>(<span class="pl-s1">url</span>=<span class="pl-s">"dubbo://192.168.12.129:20812"</span>,<span class="pl-s1">check</span>=<span class="pl-c1">false</span>)
	<span class="pl-k">public</span> <span class="pl-smi">RoleInterface</span> <span class="pl-s1">roleInterface</span>;
	<span class="pl-k">public</span> <span class="pl-smi">Object</span> <span class="pl-s1">getRole</span>(<span class="pl-smi">long</span> <span class="pl-s1">id</span>) {
 		<span class="pl-k">return</span> <span class="pl-s1">roleInterface</span>.<span class="pl-en">getRole</span>(<span class="pl-k">new</span> <span class="pl-smi">RoleDTO</span>());
	}</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!

org.apache.dubbo.rpc.RpcException: Failed to invoke remote method: getRole, provider: dubbo://192.168.12.129:20812/com.hrpackage.hrssc.security.interfaces.RoleInterface?application=hrssc-web-portal&amp;check=false&amp;dubbo=2.0.2&amp;interface=com.hrpackage.hrssc.security.interfaces.RoleInterface&amp;lazy=false&amp;methods=getRole&amp;pid=8856&amp;register.ip=192.168.12.129&amp;revision=1.0.0-SNAPSHOT&amp;side=consumer&amp;sticky=false&amp;timeout=100000000&amp;timestamp=1564397818303, cause: org.apache.dubbo.remoting.RemotingException: io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:129)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:265)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:106)
	at org.apache.dubbo.remoting.transport.netty4.NettyClientHandler.write(NettyClientHandler.java:87)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.access$2000(DefaultChannelHandlerContext.java:28)
	at io.netty.channel.DefaultChannelHandlerContext$WriteTask.run(DefaultChannelHandlerContext.java:891)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:87)
	at org.apache.dubbo.remoting.transport.netty4.NettyBackedChannelBuffer.writerIndex(NettyBackedChannelBuffer.java:440)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encodeRequest(ExchangeCodec.java:232)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:69)
	at org.apache.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:40)
	at org.apache.dubbo.remoting.transport.netty4.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:70)
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:111)
	... 16 more

	at org.apache.dubbo.rpc.protocol.AsyncToSyncInvoker.invoke(AsyncToSyncInvoker.java:63)
	at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:92)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82)
	at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:54)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82)
	at org.apache.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:58)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$CallbackRegistrationInvoker.invoke(ProtocolFilterWrapper.java:150)
	at org.apache.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:78)
	at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:55)
	at org.apache.dubbo.common.bytecode.proxy0.getRole(proxy0.java)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler.invoke(ReferenceAnnotationBeanPostProcessor.java:164)
	at com.sun.proxy.$Proxy29.getRole(Unknown Source)
	at com.hrpackage.hrssc.web.filter.Config.getRole(Config.java:25)
	at com.hrpackage.hrssc.web.filter.TokenFilter.doFilter(TokenFilter.java:35)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: org.apache.dubbo.remoting.RemotingException: io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:129)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:265)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:106)
	at org.apache.dubbo.remoting.transport.netty4.NettyClientHandler.write(NettyClientHandler.java:87)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.access$2000(DefaultChannelHandlerContext.java:28)
	at io.netty.channel.DefaultChannelHandlerContext$WriteTask.run(DefaultChannelHandlerContext.java:891)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:87)
	at org.apache.dubbo.remoting.transport.netty4.NettyBackedChannelBuffer.writerIndex(NettyBackedChannelBuffer.java:440)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encodeRequest(ExchangeCodec.java:232)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:69)
	at org.apache.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:40)
	at org.apache.dubbo.remoting.transport.netty4.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:70)
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:111)
	... 16 more

	at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
	at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
	at org.apache.dubbo.rpc.protocol.AsyncToSyncInvoker.invoke(AsyncToSyncInvoker.java:54)
	... 37 more
Caused by: org.apache.dubbo.remoting.RemotingException: io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:129)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:265)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:106)
	at org.apache.dubbo.remoting.transport.netty4.NettyClientHandler.write(NettyClientHandler.java:87)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.access$2000(DefaultChannelHandlerContext.java:28)
	at io.netty.channel.DefaultChannelHandlerContext$WriteTask.run(DefaultChannelHandlerContext.java:891)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:87)
	at org.apache.dubbo.remoting.transport.netty4.NettyBackedChannelBuffer.writerIndex(NettyBackedChannelBuffer.java:440)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encodeRequest(ExchangeCodec.java:232)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:69)
	at org.apache.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:40)
	at org.apache.dubbo.remoting.transport.netty4.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:70)
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:111)
	... 16 more

	at org.apache.dubbo.remoting.exchange.support.DefaultFuture.doReceived(DefaultFuture.java:191)
	at org.apache.dubbo.remoting.exchange.support.DefaultFuture.received(DefaultFuture.java:153)
	at org.apache.dubbo.remoting.exchange.support.DefaultFuture.received(DefaultFuture.java:141)
	at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleResponse(HeaderExchangeHandler.java:62)
	at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:199)
	at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:51)
	at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	... 1 more"><pre class="notranslate"><code class="notranslate">Just put your stack trace here!

org.apache.dubbo.rpc.RpcException: Failed to invoke remote method: getRole, provider: dubbo://192.168.12.129:20812/com.hrpackage.hrssc.security.interfaces.RoleInterface?application=hrssc-web-portal&amp;check=false&amp;dubbo=2.0.2&amp;interface=com.hrpackage.hrssc.security.interfaces.RoleInterface&amp;lazy=false&amp;methods=getRole&amp;pid=8856&amp;register.ip=192.168.12.129&amp;revision=1.0.0-SNAPSHOT&amp;side=consumer&amp;sticky=false&amp;timeout=100000000&amp;timestamp=1564397818303, cause: org.apache.dubbo.remoting.RemotingException: io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:129)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:265)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:106)
	at org.apache.dubbo.remoting.transport.netty4.NettyClientHandler.write(NettyClientHandler.java:87)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.access$2000(DefaultChannelHandlerContext.java:28)
	at io.netty.channel.DefaultChannelHandlerContext$WriteTask.run(DefaultChannelHandlerContext.java:891)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:87)
	at org.apache.dubbo.remoting.transport.netty4.NettyBackedChannelBuffer.writerIndex(NettyBackedChannelBuffer.java:440)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encodeRequest(ExchangeCodec.java:232)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:69)
	at org.apache.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:40)
	at org.apache.dubbo.remoting.transport.netty4.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:70)
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:111)
	... 16 more

	at org.apache.dubbo.rpc.protocol.AsyncToSyncInvoker.invoke(AsyncToSyncInvoker.java:63)
	at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:92)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82)
	at org.apache.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:54)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82)
	at org.apache.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:58)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:82)
	at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$CallbackRegistrationInvoker.invoke(ProtocolFilterWrapper.java:150)
	at org.apache.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:78)
	at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:55)
	at org.apache.dubbo.common.bytecode.proxy0.getRole(proxy0.java)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor$ReferenceBeanInvocationHandler.invoke(ReferenceAnnotationBeanPostProcessor.java:164)
	at com.sun.proxy.$Proxy29.getRole(Unknown Source)
	at com.hrpackage.hrssc.web.filter.Config.getRole(Config.java:25)
	at com.hrpackage.hrssc.web.filter.TokenFilter.doFilter(TokenFilter.java:35)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: org.apache.dubbo.remoting.RemotingException: io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:129)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:265)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:106)
	at org.apache.dubbo.remoting.transport.netty4.NettyClientHandler.write(NettyClientHandler.java:87)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.access$2000(DefaultChannelHandlerContext.java:28)
	at io.netty.channel.DefaultChannelHandlerContext$WriteTask.run(DefaultChannelHandlerContext.java:891)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:87)
	at org.apache.dubbo.remoting.transport.netty4.NettyBackedChannelBuffer.writerIndex(NettyBackedChannelBuffer.java:440)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encodeRequest(ExchangeCodec.java:232)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:69)
	at org.apache.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:40)
	at org.apache.dubbo.remoting.transport.netty4.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:70)
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:111)
	... 16 more

	at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
	at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
	at org.apache.dubbo.rpc.protocol.AsyncToSyncInvoker.invoke(AsyncToSyncInvoker.java:54)
	... 37 more
Caused by: org.apache.dubbo.remoting.RemotingException: io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:129)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.handler.timeout.IdleStateHandler.write(IdleStateHandler.java:265)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:698)
	at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:637)
	at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:106)
	at org.apache.dubbo.remoting.transport.netty4.NettyClientHandler.write(NettyClientHandler.java:87)
	at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:644)
	at io.netty.channel.DefaultChannelHandlerContext.access$2000(DefaultChannelHandlerContext.java:28)
	at io.netty.channel.DefaultChannelHandlerContext$WriteTask.run(DefaultChannelHandlerContext.java:891)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:348)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) &lt;= writerIndex &lt;= capacity(0))
	at io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:87)
	at org.apache.dubbo.remoting.transport.netty4.NettyBackedChannelBuffer.writerIndex(NettyBackedChannelBuffer.java:440)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encodeRequest(ExchangeCodec.java:232)
	at org.apache.dubbo.remoting.exchange.codec.ExchangeCodec.encode(ExchangeCodec.java:69)
	at org.apache.dubbo.rpc.protocol.dubbo.DubboCountCodec.encode(DubboCountCodec.java:40)
	at org.apache.dubbo.remoting.transport.netty4.NettyCodecAdapter$InternalEncoder.encode(NettyCodecAdapter.java:70)
	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:111)
	... 16 more

	at org.apache.dubbo.remoting.exchange.support.DefaultFuture.doReceived(DefaultFuture.java:191)
	at org.apache.dubbo.remoting.exchange.support.DefaultFuture.received(DefaultFuture.java:153)
	at org.apache.dubbo.remoting.exchange.support.DefaultFuture.received(DefaultFuture.java:141)
	at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleResponse(HeaderExchangeHandler.java:62)
	at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:199)
	at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:51)
	at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	... 1 more
</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/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: master</li>
<li>Operating System version: any</li>
<li>Java version: any</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>no step</li>
</ol>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="package org.apache.dubbo.config;
public class RegistryConfig extends AbstractConfig {
......
    public void setUsername(String username) {
        checkName(&quot;username&quot;, username);
        this.username = username;
    }
......
    public void setPassword(String password) {
        checkLength(&quot;password&quot;, password);
        this.password = password;
    }
......
}"><pre class="notranslate"><code class="notranslate">package org.apache.dubbo.config;
public class RegistryConfig extends AbstractConfig {
......
    public void setUsername(String username) {
        checkName("username", username);
        this.username = username;
    }
......
    public void setPassword(String password) {
        checkLength("password", password);
        this.password = password;
    }
......
}
</code></pre></div>
<p dir="auto">some property name use hard code String. actually they was defined in org.apache.dubbo.common.Constants.</p>
<p dir="auto">the following is a list of hard code Strings in RegistryConfig and the correct Constrants.<br>
"username" - &gt;Constants.USERNAME_KEY<br>
"password" - &gt;Constants.PASSWORD_KEY<br>
"file" - &gt; Constants.FILE_KEY<br>
"client" - &gt; Constants.CLIENT_KEY</p>
<p dir="auto">What do you expected from the above steps？</p>
<p dir="auto">the hard code String should be replace by constants</p>
<p dir="auto">What actually happens?</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=""><pre class="notranslate"><code class="notranslate">
</code></pre></div>