Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #8929] Proxy adds message body empty check when send in grpc protocol #8930

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ maven_install(
"org.bouncycastle:bcpkix-jdk15on:1.69",
"com.google.code.gson:gson:2.8.9",
"com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2",
"org.apache.rocketmq:rocketmq-proto:2.0.3",
"org.apache.rocketmq:rocketmq-proto:2.0.4",
"com.google.protobuf:protobuf-java:3.20.1",
"com.google.protobuf:protobuf-java-util:3.20.1",
"com.conversantmedia:disruptor:1.2.10",
Expand Down
20 changes: 9 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<annotations-api.version>6.0.53</annotations-api.version>
<extra-enforcer-rules.version>1.0-beta-4</extra-enforcer-rules.version>
<concurrentlinkedhashmap-lru.version>1.4.2</concurrentlinkedhashmap-lru.version>
<rocketmq-proto.version>2.0.3</rocketmq-proto.version>
<rocketmq-proto.version>2.0.4</rocketmq-proto.version>
<grpc.version>1.53.0</grpc.version>
<protobuf.version>3.20.1</protobuf.version>
<disruptor.version>1.2.10</disruptor.version>
Expand Down Expand Up @@ -641,16 +641,8 @@
<version>${rocketmq-proto.version}</version>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand Down Expand Up @@ -1097,6 +1089,12 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>1.3.5</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ public class ProxyConfig implements ConfigFile {
* max message body size, 0 or negative number means no limit for proxy
*/
private int maxMessageSize = 4 * 1024 * 1024;
/**
* if true, proxy will check message body size and reject msg if it's body is empty
*/
private boolean enableMessageBodyEmptyCheck = true;
/**
* max user property size, 0 or negative number means no limit for proxy
*/
Expand Down Expand Up @@ -1525,4 +1529,12 @@ public boolean isEnableBatchAck() {
public void setEnableBatchAck(boolean enableBatchAck) {
this.enableBatchAck = enableBatchAck;
}

public boolean isEnableMessageBodyEmptyCheck() {
return enableMessageBodyEmptyCheck;
}

public void setEnableMessageBodyEmptyCheck(boolean enableMessageBodyEmptyCheck) {
this.enableMessageBodyEmptyCheck = enableMessageBodyEmptyCheck;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ protected int buildSysFlag(apache.rocketmq.v2.Message protoMessage) {
}

protected void validateMessageBodySize(ByteString body) {
if (ConfigurationManager.getProxyConfig().isEnableMessageBodyEmptyCheck()) {
if (body.isEmpty()) {
throw new GrpcProxyException(Code.MESSAGE_BODY_EMPTY, "message body cannot be empty");
}
}
int max = ConfigurationManager.getProxyConfig().getMaxMessageSize();
if (max <= 0) {
return;
Expand Down
Loading