Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ public com.aliyun.dypnsapi20170525.Client smsClient() {
config.accessKeyId = aliyunAccessKeyProperties.getAccessKeyId(); // 必填
config.accessKeySecret = aliyunAccessKeyProperties.getAccessKeySecret(); // 必填

// 添加日志输出(注意:生产环境中不要打印密钥信息)
log.info("AccessKeyId: {}", config.accessKeyId);
log.info("AccessKeySecret: {}", config.accessKeySecret);
log.info("阿里云短信客户端初始化成功");

return new com.aliyun.dypnsapi20170525.Client(config);
Comment on lines +30 to 32

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

当前日志“阿里云短信客户端初始化成功”在创建 Client 实例之前打印。由于 new com.aliyun.dypnsapi20170525.Client(config) 可能会抛出异常并被 catch 块捕获,如果在实例化时发生异常,日志中仍会先输出“初始化成功”的信息,随后又输出错误日志,这会产生误导。建议在成功创建 Client 实例后再打印成功日志。

Suggested change
log.info("阿里云短信客户端初始化成功");
return new com.aliyun.dypnsapi20170525.Client(config);
com.aliyun.dypnsapi20170525.Client client = new com.aliyun.dypnsapi20170525.Client(config);
log.info("阿里云短信客户端初始化成功");
return client;

} catch (Exception e) {
Expand Down
Loading