Issue 1:
I have searched the issues of this repository and believe that this is not a duplicate.

I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

Dubbo version: 2.7.3

Operating System version: win10

Java version: 1.8

Steps to reproduce this issue

dubbo client is web project deployed in tomcat，and start up successfull。

when i call _ roleInterface.getRole(new RoleDTO());_

an exception raised ，here my code and stack trace followed，

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

What do you expected from the above steps？

Actual Result

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("token");
RoleDTO dto = new RoleDTO();

dto.setId(id);
dto.setName("test");
return dto;
}

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

}

@Reference(url="dubbo://192.168.12.129:20812",check=false)
public RoleInterface roleInterface;
public Object getRole(long id) {
return roleInterface.getRole(new RoleDTO());
}

If there is an exception, please attach the exception trace:

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&check=false&dubbo=2.0.2&interface=com.hrpackage.hrssc.security.interfaces.RoleInterface&lazy=false&methods=getRole&pid=8856&register.ip=192.168.12.129&revision=1.0.0-SNAPSHOT&side=consumer&sticky=false&timeout=100000000&timestamp=1564397818303, cause: org.apache.dubbo.remoting.RemotingException: io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) <= writerIndex <= capacity(0))
io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) <= writerIndex <= 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) <= writerIndex <= 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) <= writerIndex <= capacity(0))
io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) <= writerIndex <= 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) <= writerIndex <= 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) <= writerIndex <= capacity(0))
io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: writerIndex: 16 (expected: readerIndex(0) <= writerIndex <= 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) <= writerIndex <= 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

Issue 2:
I have searched the issues of this repository and believe that this is not a duplicate.

I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

Dubbo version: master

Operating System version: any

Java version: any

Steps to reproduce this issue

no step

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

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;
}
......
}

some property name use hard code String. actually they was defined in org.apache.dubbo.common.Constants.

the following is a list of hard code Strings in RegistryConfig and the correct Constrants.

"username" - >Constants.USERNAME_KEY

"password" - >Constants.PASSWORD_KEY

"file" - > Constants.FILE_KEY

"client" - > Constants.CLIENT_KEY

What do you expected from the above steps？

the hard code String should be replace by constants

What actually happens?

If there is an exception, please attach the exception trace: