From dcd17163c92bb9dbca3af295abc63a095e996b11 Mon Sep 17 00:00:00 2001 From: JamesChenX Date: Sat, 21 Dec 2024 17:35:19 +0800 Subject: [PATCH] Add missing cause when throwing exceptions --- .../gateway/domain/session/manager/HeartbeatManager.java | 3 ++- .../java/im/turms/plugin/push/core/smtp/SmtpSession.java | 2 +- .../common/access/admin/web/HttpRequestDispatcher.java | 3 ++- .../turms/server/common/infra/client/TurmsTcpClient.java | 2 +- .../common/infra/cluster/service/rpc/RpcService.java | 2 +- .../logging/core/appender/file/RollingFileAppender.java | 8 ++++---- .../turms/server/common/infra/plugin/PluginManager.java | 3 ++- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/turms-gateway/src/main/java/im/turms/gateway/domain/session/manager/HeartbeatManager.java b/turms-gateway/src/main/java/im/turms/gateway/domain/session/manager/HeartbeatManager.java index 2874d08a97..d2ff2eebec 100644 --- a/turms-gateway/src/main/java/im/turms/gateway/domain/session/manager/HeartbeatManager.java +++ b/turms-gateway/src/main/java/im/turms/gateway/domain/session/manager/HeartbeatManager.java @@ -236,7 +236,8 @@ private Long closeOrUpdateSession(UserSession session, long nowNanos) { t -> LOGGER.error( "Caught an error while closing the local user session ({}) with the close reason: {}", session, - HEARTBEAT_TIMEOUT)); + HEARTBEAT_TIMEOUT, + t)); return null; } session.setLastHeartbeatUpdateTimestampNanos(nowNanos); diff --git a/turms-plugins/turms-plugin-push/src/main/java/im/turms/plugin/push/core/smtp/SmtpSession.java b/turms-plugins/turms-plugin-push/src/main/java/im/turms/plugin/push/core/smtp/SmtpSession.java index 352d2ffe46..a33e807f9a 100644 --- a/turms-plugins/turms-plugin-push/src/main/java/im/turms/plugin/push/core/smtp/SmtpSession.java +++ b/turms-plugins/turms-plugin-push/src/main/java/im/turms/plugin/push/core/smtp/SmtpSession.java @@ -152,7 +152,7 @@ private static Mono onConnected( session.establish(ehloHostname, username, password, accessToken, startTls) .subscribe(null, t -> { LOGGER.error("Failed to establish the SMTP session: " - + session.id); + + session.id, t); session.onClose(connectSink, t); }, () -> { LOGGER.info("Established the SMTP session: " diff --git a/turms-server-common/src/main/java/im/turms/server/common/access/admin/web/HttpRequestDispatcher.java b/turms-server-common/src/main/java/im/turms/server/common/access/admin/web/HttpRequestDispatcher.java index b9ac99d35d..586631f65f 100644 --- a/turms-server-common/src/main/java/im/turms/server/common/access/admin/web/HttpRequestDispatcher.java +++ b/turms-server-common/src/main/java/im/turms/server/common/access/admin/web/HttpRequestDispatcher.java @@ -249,7 +249,8 @@ private void notifyEndpointChangeListeners(Map keyT } catch (Exception e) { LOGGER.error("Caught an error while notifying the endpoint change listener: " + listener.getClass() - .getName()); + .getName(), + e); } } } diff --git a/turms-server-common/src/main/java/im/turms/server/common/infra/client/TurmsTcpClient.java b/turms-server-common/src/main/java/im/turms/server/common/infra/client/TurmsTcpClient.java index 8b0d551c5a..0d2ad8892a 100644 --- a/turms-server-common/src/main/java/im/turms/server/common/infra/client/TurmsTcpClient.java +++ b/turms-server-common/src/main/java/im/turms/server/common/infra/client/TurmsTcpClient.java @@ -148,7 +148,7 @@ public Mono sendRequest(TurmsRequest.Builder requestBuilder) @Override public Mono sendRequest(TurmsRequest request) { if (connection == null) { - return Mono.error(new IllegalStateException("The connection has not established")); + return Mono.error(new IllegalStateException("The connection has not been established")); } if (connection.isDisposed()) { return Mono.error(new IllegalStateException("The connection has been closed")); diff --git a/turms-server-common/src/main/java/im/turms/server/common/infra/cluster/service/rpc/RpcService.java b/turms-server-common/src/main/java/im/turms/server/common/infra/cluster/service/rpc/RpcService.java index e41f83dfdb..b1fffa83ea 100644 --- a/turms-server-common/src/main/java/im/turms/server/common/infra/cluster/service/rpc/RpcService.java +++ b/turms-server-common/src/main/java/im/turms/server/common/infra/cluster/service/rpc/RpcService.java @@ -566,7 +566,7 @@ private Mono> requestResponsesAsMap( .isActive()) { return Mono.error(RpcException.get(RpcErrorCode.CONNECTION_NOT_FOUND, ResponseStatusCode.SERVER_UNAVAILABLE, - "Some connections have not established")); + "Some connections have not been established")); } return Mono.deferContextual(context -> { addTraceIdToRequestFromContext(context, request); diff --git a/turms-server-common/src/main/java/im/turms/server/common/infra/logging/core/appender/file/RollingFileAppender.java b/turms-server-common/src/main/java/im/turms/server/common/infra/logging/core/appender/file/RollingFileAppender.java index 14a6b32b4e..a591a1975a 100644 --- a/turms-server-common/src/main/java/im/turms/server/common/infra/logging/core/appender/file/RollingFileAppender.java +++ b/turms-server-common/src/main/java/im/turms/server/common/infra/logging/core/appender/file/RollingFileAppender.java @@ -468,15 +468,15 @@ private void deleteLogFile(LogFile file) { try { Files.deleteIfExists(path); } catch (Exception e) { - InternalLogger.INSTANCE.error("Caught an error while delete the log file: " - + path); + InternalLogger.INSTANCE.error("Caught an error while deleting the log file: " + + path, e); } if (archivePath != null) { try { Files.deleteIfExists(archivePath); } catch (Exception e) { - InternalLogger.INSTANCE.error("Caught an error while delete the log file: " - + archivePath); + InternalLogger.INSTANCE.error("Caught an error while deleting the log file: " + + archivePath, e); } } } diff --git a/turms-server-common/src/main/java/im/turms/server/common/infra/plugin/PluginManager.java b/turms-server-common/src/main/java/im/turms/server/common/infra/plugin/PluginManager.java index 6db50ca7b5..23e0a7b290 100644 --- a/turms-server-common/src/main/java/im/turms/server/common/infra/plugin/PluginManager.java +++ b/turms-server-common/src/main/java/im/turms/server/common/infra/plugin/PluginManager.java @@ -338,7 +338,8 @@ private Mono loadNetworkPlugin(HttpClient client, NetworkPluginProperties } catch (Exception e) { return Mono.error(new IllegalArgumentException( "Invalid plugin URL: " - + url)); + + url, + e)); } String fileName = Paths.get(uri.getPath()) .getFileName()