代码拉取完成,页面将自动刷新
From f0f15b5e21acd3caf9141375be5db3ef726a2173 Mon Sep 17 00:00:00 2001
From: guyinyou <36399867+guyinyou@users.noreply.github.com>
Date: Thu, 19 Oct 2023 10:14:29 +0800
Subject: [PATCH 1/2] [ISSUE #7454] Utilizing cache to avoid duplicate parsing
(#7455)
* Utilizing cache to avoid duplicate parsing
* add a method argument to decide cacheable
* Renaming variable names from cacheAble to isCached
---------
Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
Co-authored-by: RongtongJin <jinrongtong16@mails.ucas.ac.cn>
---
.../broker/processor/PopMessageProcessor.java | 2 +-
.../remoting/protocol/RemotingCommand.java | 14 ++++++++++++--
.../protocol/header/FastCodesHeaderTest.java | 2 +-
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java
index f5d07c5aa..7ed4d53ab 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/PopMessageProcessor.java
@@ -204,7 +204,7 @@ public class PopMessageProcessor implements NettyRequestProcessor {
RemotingCommand response = RemotingCommand.createResponseCommand(PopMessageResponseHeader.class);
final PopMessageResponseHeader responseHeader = (PopMessageResponseHeader) response.readCustomHeader();
final PopMessageRequestHeader requestHeader =
- (PopMessageRequestHeader) request.decodeCommandCustomHeader(PopMessageRequestHeader.class);
+ (PopMessageRequestHeader) request.decodeCommandCustomHeader(PopMessageRequestHeader.class, true);
StringBuilder startOffsetInfo = new StringBuilder(64);
StringBuilder msgOffsetInfo = new StringBuilder(64);
StringBuilder orderCountInfo = null;
diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
index d27135132..e93072adf 100644
--- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
+++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
@@ -89,6 +89,7 @@ public class RemotingCommand {
private String remark;
private HashMap<String, String> extFields;
private transient CommandCustomHeader customHeader;
+ private transient CommandCustomHeader cachedHeader;
private SerializeType serializeTypeCurrentRPC = serializeTypeConfigInThisServer;
@@ -260,10 +261,19 @@ public class RemotingCommand {
public CommandCustomHeader decodeCommandCustomHeader(
Class<? extends CommandCustomHeader> classHeader) throws RemotingCommandException {
- return decodeCommandCustomHeader(classHeader, true);
+ return decodeCommandCustomHeader(classHeader, false);
}
- public CommandCustomHeader decodeCommandCustomHeader(Class<? extends CommandCustomHeader> classHeader,
+ public CommandCustomHeader decodeCommandCustomHeader(
+ Class<? extends CommandCustomHeader> classHeader, boolean isCached) throws RemotingCommandException {
+ if (isCached && cachedHeader != null) {
+ return cachedHeader;
+ }
+ cachedHeader = decodeCommandCustomHeaderDirectly(classHeader, true);
+ return cachedHeader;
+ }
+
+ public CommandCustomHeader decodeCommandCustomHeaderDirectly(Class<? extends CommandCustomHeader> classHeader,
boolean useFastEncode) throws RemotingCommandException {
CommandCustomHeader objectHeader;
try {
diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/header/FastCodesHeaderTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/header/FastCodesHeaderTest.java
index 6bb100f57..b6a0d6311 100644
--- a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/header/FastCodesHeaderTest.java
+++ b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/header/FastCodesHeaderTest.java
@@ -73,7 +73,7 @@ public class FastCodesHeaderTest {
private void check(RemotingCommand command, List<Field> fields,
Class<? extends CommandCustomHeader> classHeader) throws Exception {
- CommandCustomHeader o1 = command.decodeCommandCustomHeader(classHeader, false);
+ CommandCustomHeader o1 = command.decodeCommandCustomHeaderDirectly(classHeader, false);
CommandCustomHeader o2 = classHeader.getDeclaredConstructor().newInstance();
((FastCodesHeader)o2).decode(command.getExtFields());
for (Field f : fields) {
--
2.32.0.windows.2
From dbc633d92b6c8c35922234611d698d3cb0a1a234 Mon Sep 17 00:00:00 2001
From: Ji Juntao <juntao.jjt@alibaba-inc.com>
Date: Thu, 19 Oct 2023 14:12:33 +0800
Subject: [PATCH 2/2] Check the input yaml and the path in ACL (#7475)
* check the input yaml and the path.
* only modify the path, no yaml.
* remove useless import
---
.../org/apache/rocketmq/acl/plain/PlainPermissionManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java
index f6699fa13..345aed06c 100644
--- a/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java
+++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionManager.java
@@ -484,7 +484,7 @@ public class PlainPermissionManager {
return false;
}
- if (!fileName.startsWith(fileHome)) {
+ if (!file.getAbsolutePath().startsWith(fileHome)) {
log.error("Parameter value " + fileName + " is not in the directory rocketmq.home.dir " + fileHome);
return false;
}
--
2.32.0.windows.2
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。