diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/LoggerCodeConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/LoggerCodeConstants.java
index 1c6b10fc94..f033d3941a 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/LoggerCodeConstants.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/LoggerCodeConstants.java
@@ -18,7 +18,20 @@
package org.apache.dubbo.common.constants;
/**
- * Constants of Error codes used in logger.
+ *
Constants of Error Codes used in logger.
+ *
+ *
Format: [Category]-[Code], where:
+ *
[Category] is the category code which identifies the module.
+ * [Code] is the detailed code.
+ * Every blanks should be filled with positive number.
+ *
+ *
+ * Hint:
+ *
Synchronize this file across different branches. (Use merge and cherry-pick.)
+ * Double-check the usage in different branches before deleting any of the error code.
+ * If applicable, use error code that already appears in this file.
+ * If it's required to add an error code, find an error code that's marked by 'Absent', and rename it. (so that no code is wasted)
+ * Update the corresponding file in dubbo-website repository.
*/
public interface LoggerCodeConstants {
@@ -222,7 +235,10 @@ public interface LoggerCodeConstants {
String PROXY_FAILED_EXPORT_SERVICE = "3-2";
- String PROXY_FAILED_JAVASSIST = "3-3";
+ /**
+ * Absent. Merged with 3-8.
+ */
+ String PROXY_33 = "3-3";
String PROXY_TIMEOUT_REQUEST = "3-4";
@@ -319,7 +335,7 @@ public interface LoggerCodeConstants {
String CONFIG_STOP_DUBBO_ERROR = "5-20";
- String CONFIG_FAILED_EXECUTE_DESTORY = "5-21";
+ String CONFIG_FAILED_EXECUTE_DESTROY = "5-21";
String CONFIG_FAILED_INIT_CONFIG_CENTER = "5-22";
@@ -366,6 +382,9 @@ public interface LoggerCodeConstants {
String TRANSPORT_FAILED_CLOSE = "6-3";
+ /**
+ * Absent. Merged to 99-0.
+ */
String TRANSPORT_UNEXPECTED_EXCEPTION = "6-4";
String TRANSPORT_FAILED_DISCONNECT_PROVIDER = "6-5";
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
index 12c62afa2e..091e4f0b58 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
@@ -82,7 +82,7 @@ import static java.lang.String.format;
import static org.apache.dubbo.common.config.ConfigurationUtils.parseProperties;
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_SPLIT_PATTERN;
import static org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_EXECUTE_DESTORY;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_EXECUTE_DESTROY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_INIT_CONFIG_CENTER;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FAILED_START_MODEL;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_REFRESH_INSTANCE_ERROR;
@@ -1124,7 +1124,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer resolvePackagesToScan(Set packagesToScan) {
- Set resolvedPackagesToScan = new LinkedHashSet(packagesToScan.size());
+ Set resolvedPackagesToScan = new LinkedHashSet<>(packagesToScan.size());
for (String packageToScan : packagesToScan) {
if (StringUtils.hasText(packageToScan)) {
String resolvedPackageToScan = environment.resolvePlaceholders(packageToScan.trim());
diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/DefaultCommandExecutor.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/DefaultCommandExecutor.java
index 6b645cfe6b..9867d72f1b 100644
--- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/DefaultCommandExecutor.java
+++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/DefaultCommandExecutor.java
@@ -16,6 +16,8 @@
*/
package org.apache.dubbo.qos.command;
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.qos.command.annotation.Cmd;
import org.apache.dubbo.qos.common.QosConstants;
import org.apache.dubbo.qos.permission.PermissionLevel;
@@ -26,6 +28,7 @@ import org.apache.dubbo.qos.permission.PermissionChecker;
import org.apache.dubbo.rpc.model.FrameworkModel;
public class DefaultCommandExecutor implements CommandExecutor {
+ private final static Logger logger = LoggerFactory.getLogger(DefaultCommandExecutor.class);
private final FrameworkModel frameworkModel;
public DefaultCommandExecutor(FrameworkModel frameworkModel) {
@@ -34,13 +37,21 @@ public class DefaultCommandExecutor implements CommandExecutor {
@Override
public String execute(CommandContext commandContext) throws NoSuchCommandException, PermissionDenyException {
+ String remoteAddress = Optional.ofNullable(commandContext.getRemote())
+ .map(Channel::remoteAddress).map(Objects::toString).orElse("unknown");
+
+ logger.info("[Dubbo QoS] Command Process start. Command: " + commandContext.getCommandName() +
+ ", Args: " + Arrays.toString(commandContext.getArgs()) + ", Remote Address: " + remoteAddress);
+
BaseCommand command = null;
try {
command = frameworkModel.getExtensionLoader(BaseCommand.class).getExtension(commandContext.getCommandName());
} catch (Throwable throwable) {
- //can't find command
+ //can't find command
}
if (command == null) {
+ logger.info("[Dubbo QoS] Command Not found. Command: " + commandContext.getCommandName() +
+ ", Remote Address: " + remoteAddress);
throw new NoSuchCommandException(commandContext.getCommandName());
}
@@ -57,10 +68,23 @@ public class DefaultCommandExecutor implements CommandExecutor {
final PermissionLevel cmdRequiredPermissionLevel = cmd.requiredPermissionLevel();
if (!permissionChecker.access(commandContext, cmdRequiredPermissionLevel)) {
+ logger.info("[Dubbo QoS] Command Deny to access. Command: " + commandContext.getCommandName() +
+ ", Args: " + Arrays.toString(commandContext.getArgs()) + ", Required Permission Level: " + cmdRequiredPermissionLevel +
+ ", Remote Address: " + remoteAddress);
throw new PermissionDenyException(commandContext.getCommandName());
}
}
- return command.execute(commandContext, commandContext.getArgs());
- }
+ try {
+ String result = command.execute(commandContext, commandContext.getArgs());
+ logger.info("[Dubbo QoS] Command Process success. Command: " + commandContext.getCommandName() +
+ ", Args: " + Arrays.toString(commandContext.getArgs()) + ", Result: " + result +
+ ", Remote Address: " + remoteAddress);
+ return result;
+ } catch (Throwable t) {
+ logger.info("[Dubbo QoS] Command Process Failed. Command: " + commandContext.getCommandName() +
+ ", Args: " + Arrays.toString(commandContext.getArgs()) +
+ ", Remote Address: " + remoteAddress, t);
+ throw t;
+ } }
}
diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java
index aab03f6f44..25d2370d4f 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeServer.java
@@ -46,7 +46,7 @@ import static java.util.Collections.unmodifiableCollection;
import static org.apache.dubbo.common.constants.CommonConstants.READONLY_EVENT;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_CLOSE;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_RESPONSE;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
import static org.apache.dubbo.remoting.Constants.HEARTBEAT_CHECK_TICK;
import static org.apache.dubbo.remoting.Constants.LEAST_HEARTBEAT_DURATION;
import static org.apache.dubbo.remoting.Constants.TICKS_PER_WHEEL;
@@ -221,7 +221,7 @@ public class HeaderExchangeServer implements ExchangeServer {
startIdleCheckTask(url);
}
} catch (Throwable t) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", t.getMessage(), t);
}
}
diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/ReconnectTimerTask.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/ReconnectTimerTask.java
index 9306f3aaf1..54a035b764 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/ReconnectTimerTask.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/ReconnectTimerTask.java
@@ -23,7 +23,7 @@ import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.Client;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_FAILED_RECONNECT;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
/**
* ReconnectTimerTask
@@ -64,7 +64,7 @@ public class ReconnectTimerTask extends AbstractTimerTask {
}
}
} catch (Throwable t) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "Exception when reconnect to remote channel " + channel.getRemoteAddress(), t);
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", "Exception when reconnect to remote channel " + channel.getRemoteAddress(), t);
}
}
}
diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java
index ed4004bdd1..16b57f1204 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractEndpoint.java
@@ -28,7 +28,7 @@ import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.remoting.transport.codec.CodecAdapter;
import org.apache.dubbo.rpc.model.FrameworkModel;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
import static org.apache.dubbo.rpc.model.ScopeModelUtil.getFrameworkModel;
/**
@@ -80,7 +80,7 @@ public abstract class AbstractEndpoint extends AbstractPeer implements Resetable
}
}
} catch (Throwable t) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
+ logger.error(INTERNAL_ERROR, "", "", t.getMessage(), t);
}
try {
@@ -88,7 +88,7 @@ public abstract class AbstractEndpoint extends AbstractPeer implements Resetable
this.codec = getChannelCodec(url);
}
} catch (Throwable t) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", t.getMessage(), t);
}
}
diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java
index b1ae4c3b5d..65978841fb 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractServer.java
@@ -36,7 +36,7 @@ import java.util.concurrent.ExecutorService;
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
import static org.apache.dubbo.config.Constants.SERVER_THREAD_POOL_NAME;
import static org.apache.dubbo.remoting.Constants.ACCEPTS_KEY;
import static org.apache.dubbo.remoting.Constants.DEFAULT_ACCEPTS;
@@ -97,7 +97,7 @@ public abstract class AbstractServer extends AbstractEndpoint implements Remotin
}
}
} catch (Throwable t) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", t.getMessage(), t);
}
ExecutorService executor = executorRepository.createExecutorIfAbsent(ExecutorUtil.setThreadName(url, SERVER_THREAD_POOL_NAME));
@@ -129,13 +129,13 @@ public abstract class AbstractServer extends AbstractEndpoint implements Remotin
try {
super.close();
} catch (Throwable e) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", e.getMessage(), e);
}
try {
doClose();
} catch (Throwable e) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", e.getMessage(), e);
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", e.getMessage(), e);
}
}
@@ -164,13 +164,13 @@ public abstract class AbstractServer extends AbstractEndpoint implements Remotin
public void connected(Channel ch) throws RemotingException {
// If the server has entered the shutdown process, reject any new connection
if (this.isClosing() || this.isClosed()) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "Close new channel " + ch + ", cause: server is closing or has been closed. For example, receive a new connect request while in shutdown process.");
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", "Close new channel " + ch + ", cause: server is closing or has been closed. For example, receive a new connect request while in shutdown process.");
ch.close();
return;
}
if (accepts > 0 && getChannelsSize()> accepts) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "Close channel " + ch + ", cause: The server " + ch.getLocalAddress() + " connections greater than max config " + accepts);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", "Close channel " + ch + ", cause: The server " + ch.getLocalAddress() + " connections greater than max config " + accepts);
ch.close();
return;
}
@@ -180,7 +180,7 @@ public abstract class AbstractServer extends AbstractEndpoint implements Remotin
@Override
public void disconnected(Channel ch) throws RemotingException {
if (getChannelsSize()==0) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "All clients has disconnected from " + ch.getLocalAddress() + ". You can graceful shutdown now.");
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", "All clients has disconnected from " + ch.getLocalAddress() + ". You can graceful shutdown now.");
}
super.disconnected(ch);
}
diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/ChannelHandlerDispatcher.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/ChannelHandlerDispatcher.java
index f425eb3ce0..c0dc2b2f84 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/ChannelHandlerDispatcher.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/ChannelHandlerDispatcher.java
@@ -26,7 +26,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.CopyOnWriteArraySet;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
/**
* ChannelListenerDispatcher
@@ -70,7 +70,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
try {
listener.connected(channel);
} catch (Throwable t) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", t.getMessage(), t);
}
}
}
@@ -81,7 +81,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
try {
listener.disconnected(channel);
} catch (Throwable t) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", t.getMessage(), t);
}
}
}
@@ -92,7 +92,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
try {
listener.sent(channel, message);
} catch (Throwable t) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", t.getMessage(), t);
}
}
}
@@ -103,7 +103,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
try {
listener.received(channel, message);
} catch (Throwable t) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", t.getMessage(), t);
}
}
}
@@ -114,7 +114,7 @@ public class ChannelHandlerDispatcher implements ChannelHandler {
try {
listener.caught(channel, exception);
} catch (Throwable t) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", t.getMessage(), t);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", t.getMessage(), t);
}
}
}
diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/MultiMessageHandler.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/MultiMessageHandler.java
index 7d65fdd757..0e78bb06b0 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/MultiMessageHandler.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/MultiMessageHandler.java
@@ -23,7 +23,7 @@ import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.RemotingException;
import org.apache.dubbo.remoting.exchange.support.MultiMessage;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
/**
* @see MultiMessage
@@ -45,11 +45,11 @@ public class MultiMessageHandler extends AbstractChannelHandlerDelegate {
try {
handler.received(channel, obj);
} catch (Throwable t) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "MultiMessageHandler received fail.", t);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", "MultiMessageHandler received fail.", t);
try {
handler.caught(channel, t);
} catch (Throwable t1) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "MultiMessageHandler caught fail.", t1);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", "MultiMessageHandler caught fail.", t1);
}
}
}
diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java
index 9af07d3b38..a250d05bf7 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/dispatcher/ChannelEventRunnable.java
@@ -22,7 +22,7 @@ import org.apache.dubbo.common.threadlocal.InternalThreadLocal;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.ChannelHandler;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
public class ChannelEventRunnable implements Runnable {
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ChannelEventRunnable.class);
@@ -60,7 +60,7 @@ public class ChannelEventRunnable implements Runnable {
try {
handler.received(channel, message);
} catch (Exception e) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel
+ ", message is " + message, e);
}
} else {
@@ -69,21 +69,21 @@ public class ChannelEventRunnable implements Runnable {
try {
handler.connected(channel);
} catch (Exception e) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel, e);
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel, e);
}
break;
case DISCONNECTED:
try {
handler.disconnected(channel);
} catch (Exception e) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel, e);
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel, e);
}
break;
case SENT:
try {
handler.sent(channel, message);
} catch (Exception e) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel
+ ", message is " + message, e);
}
break;
@@ -91,12 +91,12 @@ public class ChannelEventRunnable implements Runnable {
try {
handler.caught(channel, exception);
} catch (Exception e) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", "ChannelEventRunnable handle " + state + " operation error, channel is " + channel
+ ", message is: " + message + ", exception is " + exception, e);
}
break;
default:
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "unknown state: " + state + ", message is " + message);
+ logger.warn(INTERNAL_ERROR, "unknown error in remoting module", "", "unknown state: " + state + ", message is " + message);
}
}
InternalThreadLocal.removeAll();
diff --git a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyHelper.java b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyHelper.java
index bfe8cafd8a..f7f70bfecd 100644
--- a/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyHelper.java
+++ b/dubbo-remoting/dubbo-remoting-netty/src/main/java/org/apache/dubbo/remoting/transport/netty/NettyHelper.java
@@ -23,7 +23,7 @@ import org.jboss.netty.logging.AbstractInternalLogger;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
final class NettyHelper {
@@ -44,6 +44,7 @@ final class NettyHelper {
static class DubboLogger extends AbstractInternalLogger {
+ public static final String LOGGER_CAUSE_STRING = "unknown error in remoting-netty module";
private ErrorTypeAwareLogger logger;
DubboLogger(ErrorTypeAwareLogger logger) {
@@ -92,22 +93,22 @@ final class NettyHelper {
@Override
public void warn(String msg) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", msg);
+ logger.warn(INTERNAL_ERROR, LOGGER_CAUSE_STRING, "", msg);
}
@Override
public void warn(String msg, Throwable cause) {
- logger.warn(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", msg, cause);
+ logger.warn(INTERNAL_ERROR, LOGGER_CAUSE_STRING, "", msg, cause);
}
@Override
public void error(String msg) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", msg);
+ logger.error(INTERNAL_ERROR, LOGGER_CAUSE_STRING, "", msg);
}
@Override
public void error(String msg, Throwable cause) {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", msg, cause);
+ logger.error(INTERNAL_ERROR, LOGGER_CAUSE_STRING, "", msg, cause);
}
@Override
diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServerHandler.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServerHandler.java
index 338f3572d1..c48372865e 100644
--- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServerHandler.java
+++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyPortUnificationServerHandler.java
@@ -39,7 +39,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
public class NettyPortUnificationServerHandler extends ByteToMessageDecoder {
@@ -71,7 +71,7 @@ public class NettyPortUnificationServerHandler extends ByteToMessageDecoder {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- LOGGER.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "Unexpected exception from downstream before protocol detected.", cause);
+ LOGGER.error(INTERNAL_ERROR, "unknown error in remoting module", "", "Unexpected exception from downstream before protocol detected.", cause);
}
@Override
@@ -125,7 +125,7 @@ public class NettyPortUnificationServerHandler extends ByteToMessageDecoder {
Set supported = url.getApplicationModel()
.getExtensionLoader(WireProtocol.class)
.getSupportedExtensions();
- LOGGER.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", String.format("Can not recognize protocol from downstream=%s . "
+ LOGGER.error(INTERNAL_ERROR, "unknown error in remoting module", "", String.format("Can not recognize protocol from downstream=%s . "
+ "preface=%s protocols=%s", ctx.channel().remoteAddress(),
Bytes.bytes2hex(preface),
supported));
diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslClientTlsHandler.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslClientTlsHandler.java
index b638e17d12..09f687dd81 100644
--- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslClientTlsHandler.java
+++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslClientTlsHandler.java
@@ -29,7 +29,7 @@ import io.netty.handler.ssl.SslHandshakeCompletionEvent;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
public class SslClientTlsHandler extends ChannelInboundHandlerAdapter {
@@ -61,7 +61,7 @@ public class SslClientTlsHandler extends ChannelInboundHandlerAdapter {
logger.info("TLS negotiation succeed with session: " + session);
ctx.pipeline().remove(this);
} else {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "TLS negotiation failed when trying to accept new connection.", handshakeEvent.cause());
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", "TLS negotiation failed when trying to accept new connection.", handshakeEvent.cause());
ctx.fireExceptionCaught(handshakeEvent.cause());
}
}
diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslServerTlsHandler.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslServerTlsHandler.java
index c92be4e8ca..a8c008b06c 100644
--- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslServerTlsHandler.java
+++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslServerTlsHandler.java
@@ -31,7 +31,7 @@ import io.netty.handler.ssl.SslHandshakeCompletionEvent;
import javax.net.ssl.SSLSession;
import java.util.List;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.TRANSPORT_UNEXPECTED_EXCEPTION;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
public class SslServerTlsHandler extends ByteToMessageDecoder {
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SslServerTlsHandler.class);
@@ -59,7 +59,7 @@ public class SslServerTlsHandler extends ByteToMessageDecoder {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "TLS negotiation failed when trying to accept new connection.", cause);
+ logger.error(INTERNAL_ERROR, "unknown error in remoting module", "", "TLS negotiation failed when trying to accept new connection.", cause);
}
@Override
@@ -72,7 +72,7 @@ public class SslServerTlsHandler extends ByteToMessageDecoder {
// Remove after handshake success.
ctx.pipeline().remove(this);
} else {
- logger.error(TRANSPORT_UNEXPECTED_EXCEPTION, "", "", "TLS negotiation failed when trying to accept new connection.", handshakeEvent.cause());
+ logger.error(INTERNAL_ERROR, "", "", "TLS negotiation failed when trying to accept new connection.", handshakeEvent.cause());
ctx.close();
}
}
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/javassist/JavassistProxyFactory.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/javassist/JavassistProxyFactory.java
index 8755a75cca..4d341b2ec9 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/javassist/JavassistProxyFactory.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/proxy/javassist/JavassistProxyFactory.java
@@ -29,7 +29,7 @@ import org.apache.dubbo.rpc.proxy.jdk.JdkProxyFactory;
import java.util.Arrays;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_FAILED_JAVASSIST;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROXY_FAILED;
/**
* JavassistRpcProxyFactory
@@ -47,13 +47,13 @@ public class JavassistProxyFactory extends AbstractProxyFactory {
// try fall back to JDK proxy factory
try {
T proxy = jdkProxyFactory.getProxy(invoker, interfaces);
- logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate proxy by Javassist failed. Fallback to use JDK proxy success. " +
+ logger.error(PROXY_FAILED, "", "", "Failed to generate proxy by Javassist failed. Fallback to use JDK proxy success. " +
"Interfaces: " + Arrays.toString(interfaces), fromJavassist);
return proxy;
} catch (Throwable fromJdk) {
- logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate proxy by Javassist failed. Fallback to use JDK proxy is also failed. " +
+ logger.error(PROXY_FAILED, "", "", "Failed to generate proxy by Javassist failed. Fallback to use JDK proxy is also failed. " +
"Interfaces: " + Arrays.toString(interfaces) + " Javassist Error.", fromJavassist);
- logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate proxy by Javassist failed. Fallback to use JDK proxy is also failed. " +
+ logger.error(PROXY_FAILED, "", "", "Failed to generate proxy by Javassist failed. Fallback to use JDK proxy is also failed. " +
"Interfaces: " + Arrays.toString(interfaces) + " JDK Error.", fromJdk);
throw fromJavassist;
}
@@ -77,14 +77,14 @@ public class JavassistProxyFactory extends AbstractProxyFactory {
// try fall back to JDK proxy factory
try {
Invoker invoker = jdkProxyFactory.getInvoker(proxy, type, url);
- logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate invoker by Javassist failed. Fallback to use JDK proxy success. " +
+ logger.error(PROXY_FAILED, "", "", "Failed to generate invoker by Javassist failed. Fallback to use JDK proxy success. " +
"Interfaces: " + type, fromJavassist);
// log out error
return invoker;
} catch (Throwable fromJdk) {
- logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate invoker by Javassist failed. Fallback to use JDK proxy is also failed. " +
+ logger.error(PROXY_FAILED, "", "", "Failed to generate invoker by Javassist failed. Fallback to use JDK proxy is also failed. " +
"Interfaces: " + type + " Javassist Error.", fromJavassist);
- logger.error(PROXY_FAILED_JAVASSIST, "", "", "Failed to generate invoker by Javassist failed. Fallback to use JDK proxy is also failed. " +
+ logger.error(PROXY_FAILED, "", "", "Failed to generate invoker by Javassist failed. Fallback to use JDK proxy is also failed. " +
"Interfaces: " + type + " JDK Error.", fromJdk);
throw fromJavassist;
}
diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/TripleClientStream.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/TripleClientStream.java
index 48da55acc1..d4ec4ef2e7 100644
--- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/TripleClientStream.java
+++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/TripleClientStream.java
@@ -19,7 +19,6 @@ package org.apache.dubbo.rpc.protocol.tri.stream;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.common.utils.JsonUtils;
import org.apache.dubbo.rpc.TriRpcStatus;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.protocol.tri.TripleHeaderEnum;
@@ -56,8 +55,6 @@ import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.concurrent.Executor;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_REFLECTIVE_OPERATION_FAILED;
-
/**
* ClientStream is an abstraction for bi-directional messaging. It maintains a {@link WriteQueue} to
@@ -236,29 +233,10 @@ public class TripleClientStream extends AbstractStream implements ClientStream {
halfClosed = true;
final Map reserved = filterReservedHeaders(trailers);
- final Map attachments = headersToMap(trailers);
- final Map finalAttachments = convertNoLowerCaseHeader(attachments);
- listener.onComplete(status, finalAttachments, reserved);
- }
-
- private Map convertNoLowerCaseHeader(Map attachments) {
- Object obj = attachments.remove(TripleHeaderEnum.TRI_HEADER_CONVERT.getHeader());
- if (obj == null) {
- return attachments;
- }
- if (obj instanceof String) {
- String json = TriRpcStatus.decodeMessage((String) obj);
- Map map = JsonUtils.getJson().toJavaObject(json, Map.class);
- map.forEach((originalKey, lowerCaseKey) -> {
- Object val = attachments.remove(lowerCaseKey);
- if (val != null) {
- attachments.put(originalKey, val);
- }
- });
- } else {
- LOGGER.error(COMMON_REFLECTIVE_OPERATION_FAILED, "", "", "Triple convertNoLowerCaseHeader error, obj is not String");
- }
- return attachments;
+ final Map attachments = headersToMap(trailers, () -> {
+ return reserved.get(TripleHeaderEnum.TRI_HEADER_CONVERT.getHeader());
+ });
+ listener.onComplete(status, attachments, reserved);
}
private TriRpcStatus validateHeaderStatus(Http2Headers headers) {
diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/TripleServerStream.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/TripleServerStream.java
index d014efddf1..dba356ae5e 100644
--- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/TripleServerStream.java
+++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/stream/TripleServerStream.java
@@ -402,7 +402,11 @@ public class TripleServerStream extends AbstractStream implements ServerStream {
}
}
- Map requestMetadata = headersToMap(headers);
+ Map requestMetadata = headersToMap(headers, () -> {
+ return Optional.ofNullable(headers.get(TripleHeaderEnum.TRI_HEADER_CONVERT.getHeader()))
+ .map(CharSequence::toString)
+ .orElse(null);
+ });
boolean hasStub = pathResolver.hasNativeStub(path);
if (hasStub) {
listener = new StubAbstractServerCall(invoker, TripleServerStream.this,
diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/AbstractH2TransportListener.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/AbstractH2TransportListener.java
index 2cf6caa001..110e0472f5 100644
--- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/AbstractH2TransportListener.java
+++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/transport/AbstractH2TransportListener.java
@@ -19,6 +19,8 @@ package org.apache.dubbo.rpc.protocol.tri.transport;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.utils.JsonUtils;
+import org.apache.dubbo.rpc.TriRpcStatus;
import org.apache.dubbo.rpc.protocol.tri.TripleConstant;
import org.apache.dubbo.rpc.protocol.tri.TripleHeaderEnum;
import org.apache.dubbo.rpc.protocol.tri.stream.StreamUtils;
@@ -28,7 +30,9 @@ import io.netty.handler.codec.http2.Http2Headers;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.function.Supplier;
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.PROTOCOL_FAILED_PARSE;
public abstract class AbstractH2TransportListener implements H2TransportListener {
@@ -41,7 +45,7 @@ public abstract class AbstractH2TransportListener implements H2TransportListener
* @param trailers the metadata from remote
* @return KV pairs map
*/
- protected Map headersToMap(Http2Headers trailers) {
+ protected Map headersToMap(Http2Headers trailers, Supplier