fix checkType errors about module hippo4j-threadpool-rpc.

pull/1288/head
DDDreame 2 years ago
parent 52131d282a
commit 2ca2c392a5

@ -49,6 +49,8 @@ public class NettyClientConnection implements ClientConnection {
* Obtain the connection timeout period. The default value is 30s
*/
long timeout = 30000L;
final int nanosPerMilliSecond = 1000000;
EventLoopGroup worker = new NioEventLoopGroup();
NettyConnectPool connectionPool;
ChannelFuture future;
@ -74,7 +76,7 @@ public class NettyClientConnection implements ClientConnection {
}
// Wait for execution to complete
ResultHolder.putThread(key, Thread.currentThread());
LockSupport.parkNanos(timeout() * 1000000);
LockSupport.parkNanos(timeout() * nanosPerMilliSecond);
response = ResultHolder.get(key);
if (response == null) {
throw new TimeOutException("Timeout waiting for server-side response");

@ -34,7 +34,8 @@ import java.io.Serializable;
*/
public class NettyEncoder extends MessageToByteEncoder<Serializable> {
private static final byte[] BYTE = new byte[4];
private static final int BYTE_LENGTH = 4;
private static final byte[] BYTE = new byte[BYTE_LENGTH];
@Override
protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception {
@ -49,6 +50,6 @@ public class NettyEncoder extends MessageToByteEncoder<Serializable> {
throw new CoderException("The encoding is abnormal, which may be caused by the transfer object being unable to be serialized");
}
int endIndex = out.writerIndex();
out.setInt(startIndex, endIndex - startIndex - 4);
out.setInt(startIndex, endIndex - startIndex - BYTE_LENGTH);
}
}

@ -73,6 +73,10 @@ public interface HandlerManager<T> {
return new HandlerEntity<>(order, handler, name);
}
/**
* handler entity
* @param <T>
*/
@Getter
@AllArgsConstructor
class HandlerEntity<T> implements Comparable<HandlerEntity<T>> {

@ -71,10 +71,12 @@ public final class DefaultRequest implements Request {
@Override
public boolean equals(Object o) {
if (this == o)
if (this == o) {
return true;
if (o == null || getClass() != o.getClass())
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DefaultRequest that = (DefaultRequest) o;
return Objects.equals(key, that.key)
&& Objects.equals(className, that.className)

@ -84,10 +84,12 @@ public class DefaultResponse implements Response {
@Override
public boolean equals(Object o) {
if (this == o)
if (this == o) {
return true;
if (o == null || getClass() != o.getClass())
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DefaultResponse that = (DefaultResponse) o;
return Objects.equals(key, that.key) && Objects.equals(cls, that.cls);
}

@ -56,6 +56,7 @@ public class NettyServerConnection extends AbstractNettyHandlerManager implement
Class<? extends ServerChannel> socketChannelCls = NioServerSocketChannel.class;
ChannelFuture future;
Channel channel;
private final int maxPortNum = 65535;
public NettyServerConnection(EventLoopGroup leader, EventLoopGroup worker, List<ChannelHandler> handlers) {
super(handlers);
@ -80,7 +81,7 @@ public class NettyServerConnection extends AbstractNettyHandlerManager implement
@Override
public void bind(ServerPort port) {
int serverPort = port.getPort();
if (serverPort < 0 || serverPort > 65535) {
if (serverPort < 0 || serverPort > maxPortNum) {
throw new ConnectionException("The port number " + serverPort + " is outside 0~65535, which is not a legal port number");
}
ServerBootstrap server = new ServerBootstrap();

Loading…
Cancel
Save