ProtocolCodec优化

This commit is contained in:
Redkale
2023-01-14 13:17:37 +08:00
parent a973834325
commit 68bfa944fe
2 changed files with 7 additions and 7 deletions

View File

@@ -33,7 +33,7 @@ public abstract class DispatcherServlet<K extends Serializable, C extends Contex
private final LongAdder executeCounter = new LongAdder(); //执行请求次数 private final LongAdder executeCounter = new LongAdder(); //执行请求次数
private final LongAdder illRequestCounter = new LongAdder(); //错误请求次数 private final LongAdder illegalRequestCounter = new LongAdder(); //错误请求次数
private final Object servletLock = new Object(); private final Object servletLock = new Object();
@@ -53,8 +53,8 @@ public abstract class DispatcherServlet<K extends Serializable, C extends Contex
executeCounter.increment(); executeCounter.increment();
} }
protected void incrIllRequestCounter() { protected void incrIllegalRequestCounter() {
illRequestCounter.increment(); illegalRequestCounter.increment();
} }
protected void putServlet(S servlet) { protected void putServlet(S servlet) {
@@ -279,7 +279,7 @@ public abstract class DispatcherServlet<K extends Serializable, C extends Contex
} }
public Long getIllRequestCounter() { public Long getIllRequestCounter() {
return illRequestCounter.longValue(); return illegalRequestCounter.longValue();
} }
} }

View File

@@ -12,7 +12,7 @@ import java.util.function.*;
import java.util.logging.Level; import java.util.logging.Level;
/** /**
* 一个AsyncConnection绑定一个ProtocolCodec实例 * 一个AsyncConnection绑定一个ProtocolCodec实例, 只会在读IOThread中运行
* *
* @author zhangjx * @author zhangjx
*/ */
@@ -146,7 +146,7 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
preparer.incrExecuteCounter(); preparer.incrExecuteCounter();
channel.offerReadBuffer(buffer); channel.offerReadBuffer(buffer);
if (rs != Integer.MIN_VALUE) { if (rs != Integer.MIN_VALUE) {
preparer.incrIllRequestCounter(); preparer.incrIllegalRequestCounter();
} }
response.finish(true); response.finish(true);
if (context.logger.isLoggable(Level.FINEST)) { if (context.logger.isLoggable(Level.FINEST)) {
@@ -197,7 +197,7 @@ class ProtocolCodec implements CompletionHandler<Integer, ByteBuffer> {
@Override @Override
public void failed(Throwable exc, ByteBuffer attachment) { public void failed(Throwable exc, ByteBuffer attachment) {
context.prepare.incrIllRequestCounter(); context.prepare.incrIllegalRequestCounter();
channel.offerReadBuffer(attachment); channel.offerReadBuffer(attachment);
response.finish(true); response.finish(true);
if (exc != null) { if (exc != null) {