SncpRequest
This commit is contained in:
@@ -22,8 +22,6 @@ public class SncpDispatcherServlet
|
||||
|
||||
private final ReentrantLock updateLock = new ReentrantLock();
|
||||
|
||||
private final ThreadLocal<ByteArray> localArray = Utility.withInitialThreadLocal(ByteArray::new);
|
||||
|
||||
protected SncpDispatcherServlet() {
|
||||
super();
|
||||
}
|
||||
@@ -84,7 +82,7 @@ public class SncpDispatcherServlet
|
||||
public void execute(SncpRequest request, SncpResponse response) throws IOException {
|
||||
try {
|
||||
if (request.isPing()) {
|
||||
ByteArray array = localArray.get().clear();
|
||||
ByteArray array = request.getTempByteArray();
|
||||
int headerSize = SncpHeader.calcHeaderSize(request);
|
||||
array.putPlaceholder(headerSize);
|
||||
response.writeHeader(array, 0, 0);
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.Serializable;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
import org.redkale.convert.*;
|
||||
import org.redkale.convert.bson.BsonReader;
|
||||
@@ -31,6 +32,10 @@ public class SncpRequest extends Request<SncpContext> {
|
||||
|
||||
protected static final int READ_STATE_END = 4;
|
||||
|
||||
private static final String tbaName = "_tba";
|
||||
|
||||
private static final Function<String, ByteArray> tbaFunc = s -> new ByteArray();
|
||||
|
||||
protected final BsonReader reader = new BsonReader();
|
||||
|
||||
protected int readState = READ_STATE_ROUTE;
|
||||
@@ -215,4 +220,8 @@ public class SncpRequest extends Request<SncpContext> {
|
||||
public SncpHeader getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public ByteArray getTempByteArray() {
|
||||
return getSubobjectIfAbsent(tbaName, tbaFunc).clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user