You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by gu...@apache.org on 2021/09/06 07:28:05 UTC
[dubbo] branch 3.0 updated: Catch some harmless exception (#8663)
This is an automated email from the ASF dual-hosted git repository.
guohao pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new fe06df6 Catch some harmless exception (#8663)
fe06df6 is described below
commit fe06df640eb535f8af05234808ca88822bb6884a
Author: earthchen <yo...@duobei.com>
AuthorDate: Mon Sep 6 15:27:57 2021 +0800
Catch some harmless exception (#8663)
---
.../tri/TripleServerConnectionHandler.java | 9 +++++-
.../apache/dubbo/rpc/protocol/tri/TripleUtil.java | 37 ++++++++++++++++++----
2 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleServerConnectionHandler.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleServerConnectionHandler.java
index f73695e..7495c80 100644
--- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleServerConnectionHandler.java
+++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleServerConnectionHandler.java
@@ -52,7 +52,14 @@ public class TripleServerConnectionHandler extends Http2ChannelDuplexHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- logger.warn(String.format("Channel:%s Error", ctx.channel()), cause);
+ // this may be change in future follow https://github.com/apache/dubbo/pull/8644
+ if (TripleUtil.isQuiteException(cause)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Channel:%s Error", ctx.channel()), cause);
+ }
+ } else {
+ logger.warn(String.format("Channel:%s Error", ctx.channel()), cause);
+ }
ctx.close();
}
diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleUtil.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleUtil.java
index 149de74..373861a 100644
--- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleUtil.java
+++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleUtil.java
@@ -16,13 +16,6 @@
*/
package org.apache.dubbo.rpc.protocol.tri;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.serialize.MultipleSerialization;
-import org.apache.dubbo.remoting.Constants;
-import org.apache.dubbo.rpc.RpcInvocation;
-import org.apache.dubbo.rpc.model.MethodDescriptor;
-import org.apache.dubbo.triple.TripleWrapper;
-
import com.google.protobuf.Any;
import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
@@ -37,17 +30,26 @@ import io.netty.handler.codec.http2.DefaultHttp2Headers;
import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame;
import io.netty.handler.codec.http2.Http2Headers;
import io.netty.util.AttributeKey;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.serialize.MultipleSerialization;
+import org.apache.dubbo.remoting.Constants;
+import org.apache.dubbo.rpc.RpcInvocation;
+import org.apache.dubbo.rpc.model.MethodDescriptor;
+import org.apache.dubbo.triple.TripleWrapper;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
+import java.net.SocketException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
@@ -58,6 +60,27 @@ public class TripleUtil {
public static final AttributeKey<AbstractClientStream> CLIENT_STREAM_KEY = AttributeKey.newInstance(
"tri_client_stream");
+ // Some exceptions are not very useful and add too much noise to the log
+ private static final Set<String> QUIET_EXCEPTIONS = new HashSet<>();
+ private static final Set<Class<?>> QUIET_EXCEPTIONS_CLASS = new HashSet<>();
+
+ static {
+ QUIET_EXCEPTIONS.add("NativeIoException");
+ QUIET_EXCEPTIONS_CLASS.add(IOException.class);
+ QUIET_EXCEPTIONS_CLASS.add(SocketException.class);
+ }
+
+ public static boolean isQuiteException(Throwable t) {
+ if (QUIET_EXCEPTIONS_CLASS.contains(t.getClass())) {
+ return true;
+ }
+ if (QUIET_EXCEPTIONS.contains(t.getClass().getSimpleName())) {
+ return true;
+ }
+ return false;
+ }
+
+
public static final String LANGUAGE = "java";
private static final Base64.Decoder BASE64_DECODER = Base64.getDecoder();