This commit is contained in:
redkale
2024-10-21 14:22:35 +08:00
parent 5da88a7916
commit c524e15267
2 changed files with 19 additions and 15 deletions

View File

@@ -521,7 +521,7 @@ abstract class AsyncNioConnection extends AsyncConnection {
} }
@Override @Override
public int read(byte b[], int off, int len) throws IOException { public int read(byte[] b, int off, int len) throws IOException {
if (b == null) { if (b == null) {
throw new NullPointerException(); throw new NullPointerException();
} else if (off < 0 || len < 0 || len > b.length - off) { } else if (off < 0 || len < 0 || len > b.length - off) {

View File

@@ -12,10 +12,9 @@ import org.redkale.util.ByteTuple;
* pipelineWrite写入包 * pipelineWrite写入包
* *
* @author zhangjx * @author zhangjx
* @param <T> attachment类型
* @since 2.8.0 * @since 2.8.0
*/ */
public class PipelinePacket<T> { public class PipelinePacket {
@ConvertColumn(index = 1) @ConvertColumn(index = 1)
protected byte[] tupleBytes; protected byte[] tupleBytes;
@@ -27,35 +26,40 @@ public class PipelinePacket<T> {
protected int tupleLength; protected int tupleLength;
@ConvertColumn(index = 4) @ConvertColumn(index = 4)
protected CompletionHandler<Integer, T> handler; protected CompletionHandler<Integer, Object> handler;
@ConvertColumn(index = 5) @ConvertColumn(index = 5)
protected T attach; protected Object attach;
public PipelinePacket() {} public PipelinePacket() {}
public PipelinePacket(ByteTuple data, CompletionHandler<Integer, T> handler) { public PipelinePacket(ByteTuple data, CompletionHandler<Integer, Object> handler) {
this(data, handler, null); this(data, handler, null);
} }
public PipelinePacket(ByteTuple data, CompletionHandler<Integer, T> handler, T attach) { public PipelinePacket(ByteTuple data, CompletionHandler<Integer, Object> handler, Object attach) {
this(data.content(), data.offset(), data.length(), handler, attach); this(data.content(), data.offset(), data.length(), handler, attach);
} }
public PipelinePacket(byte[] tupleBytes, CompletionHandler<Integer, T> handler) { public PipelinePacket(byte[] tupleBytes, CompletionHandler<Integer, Object> handler) {
this(tupleBytes, 0, tupleBytes.length, handler, null); this(tupleBytes, 0, tupleBytes.length, handler, null);
} }
public PipelinePacket(byte[] tupleBytes, CompletionHandler<Integer, T> handler, T attach) { public PipelinePacket(byte[] tupleBytes, CompletionHandler<Integer, Object> handler, Object attach) {
this(tupleBytes, 0, tupleBytes.length, handler, attach); this(tupleBytes, 0, tupleBytes.length, handler, attach);
} }
public PipelinePacket(byte[] tupleBytes, int tupleOffset, int tupleLength, CompletionHandler<Integer, T> handler) { public PipelinePacket(
byte[] tupleBytes, int tupleOffset, int tupleLength, CompletionHandler<Integer, Object> handler) {
this(tupleBytes, tupleOffset, tupleLength, handler, null); this(tupleBytes, tupleOffset, tupleLength, handler, null);
} }
public PipelinePacket( public PipelinePacket(
byte[] tupleBytes, int tupleOffset, int tupleLength, CompletionHandler<Integer, T> handler, T attach) { byte[] tupleBytes,
int tupleOffset,
int tupleLength,
CompletionHandler<Integer, Object> handler,
Object attach) {
this.tupleBytes = tupleBytes; this.tupleBytes = tupleBytes;
this.tupleOffset = tupleOffset; this.tupleOffset = tupleOffset;
this.tupleLength = tupleLength; this.tupleLength = tupleLength;
@@ -87,19 +91,19 @@ public class PipelinePacket<T> {
this.tupleLength = tupleLength; this.tupleLength = tupleLength;
} }
public CompletionHandler<Integer, T> getHandler() { public CompletionHandler<Integer, Object> getHandler() {
return handler; return handler;
} }
public void setHandler(CompletionHandler<Integer, T> handler) { public void setHandler(CompletionHandler<Integer, Object> handler) {
this.handler = handler; this.handler = handler;
} }
public T getAttach() { public Object getAttach() {
return attach; return attach;
} }
public void setAttach(T attach) { public void setAttach(Object attach) {
this.attach = attach; this.attach = attach;
} }
} }