优化
This commit is contained in:
@@ -144,8 +144,7 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
||||
}
|
||||
}
|
||||
|
||||
protected void decode(
|
||||
final ByteBuffer buffer, final Response response, final int pipelineIndex, final Request lastReq) {
|
||||
protected void decode(ByteBuffer buffer, Response response, int pipelineIndex, Request lastReq) {
|
||||
response.init(channel);
|
||||
final Request request = response.request;
|
||||
final int rs = request.readHeader(buffer, lastReq);
|
||||
@@ -163,12 +162,8 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
||||
} else if (rs == 0) {
|
||||
context.dispatcher.incrExecuteCounter();
|
||||
int pindex = pipelineIndex;
|
||||
boolean pipeline = false;
|
||||
boolean seted = false;
|
||||
boolean completed = request.completed;
|
||||
Request hreq = lastReq;
|
||||
if (buffer.hasRemaining()) {
|
||||
pipeline = true;
|
||||
if (buffer.hasRemaining()) { // pipeline模式
|
||||
if (pindex == 0) {
|
||||
pindex++;
|
||||
}
|
||||
@@ -178,15 +173,7 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
||||
if (hreq == null) {
|
||||
hreq = request.copyHeader();
|
||||
}
|
||||
} else {
|
||||
if (request.getRequestid() == null) { // 存在requestid则无视pipeline模式
|
||||
request.pipeline(pindex, pindex);
|
||||
}
|
||||
channel.setReadBuffer(buffer.clear());
|
||||
seted = true;
|
||||
}
|
||||
context.executeDispatch(request, response);
|
||||
if (pipeline) {
|
||||
context.executeDispatch(request, response);
|
||||
final Response pipelineResponse = createResponse();
|
||||
try {
|
||||
decode(buffer, pipelineResponse, pindex + 1, hreq);
|
||||
@@ -194,13 +181,15 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
|
||||
context.logger.log(Level.WARNING, "dispatch pipeline servlet abort, force to close channel ", t);
|
||||
pipelineResponse.codecError(t);
|
||||
}
|
||||
} else if (completed) {
|
||||
if (!seted) {
|
||||
channel.setReadBuffer(buffer.clear());
|
||||
} else {
|
||||
if (request.getRequestid() == null) { // 存在requestid则无视pipeline模式
|
||||
request.pipeline(pindex, pindex);
|
||||
}
|
||||
channel.setReadBuffer(buffer.clear());
|
||||
context.executeDispatch(request, response);
|
||||
channel.readRegister(this);
|
||||
}
|
||||
} else {
|
||||
} else { // rs > 0
|
||||
channel.setReadBuffer(buffer);
|
||||
channel.read(readHandler.prepare(request, response, pipelineIndex, lastReq));
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class HttpContext extends Context {
|
||||
protected final AnyValue rpcAuthenticatorConfig;
|
||||
|
||||
// 延迟解析header
|
||||
protected final boolean lazyHeaders; // 存在动态改值
|
||||
protected final boolean lazyHeaders;
|
||||
|
||||
// 不带通配符的mapping url的缓存对象
|
||||
final Map<ByteArray, String>[] uriPathCaches = new Map[100];
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import org.redkale.convert.ConvertDisabled;
|
||||
import org.redkale.convert.TextConvert;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.util.RedkaleException;
|
||||
@@ -164,6 +165,7 @@ public class HttpParameters implements RestParams, Serializable {
|
||||
return this.map;
|
||||
}
|
||||
|
||||
@ConvertDisabled
|
||||
public boolean isEmpty() {
|
||||
return this.map == null || this.map.isEmpty();
|
||||
}
|
||||
|
||||
@@ -1670,6 +1670,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
*
|
||||
* @return Annotation[]
|
||||
*/
|
||||
@Override
|
||||
@ConvertDisabled
|
||||
public Annotation[] getAnnotations() {
|
||||
if (this.annotations == null) {
|
||||
@@ -1687,6 +1688,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
* @param annotationClass 注解类型
|
||||
* @return Annotation
|
||||
*/
|
||||
@Override
|
||||
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
|
||||
if (this.annotations == null) {
|
||||
return null;
|
||||
@@ -1706,6 +1708,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
* @param annotationClass 注解类型
|
||||
* @return Annotation[]
|
||||
*/
|
||||
@Override
|
||||
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
|
||||
if (this.annotations == null) {
|
||||
return Creator.newArray(annotationClass, 0);
|
||||
|
||||
Reference in New Issue
Block a user