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

support handle empty response content #363

Merged
merged 13 commits into from
Nov 27, 2024
Merged
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.alipay.sofa</groupId>
<artifactId>bolt</artifactId>
<version>1.6.10</version>
<version>1.6.11-SNAPSHOT</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) thro
header = new byte[headerLen];
in.readBytes(header);
}
if (contentLen > 0) {
if (contentLen == 0) {
content = new byte[0];
} else if (contentLen > 0) {
content = new byte[contentLen];
in.readBytes(content);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) thro
header = new byte[headerLen];
in.readBytes(header);
}
if (contentLen > 0) {
if (contentLen == 0) {
content = new byte[0];
} else if (contentLen > 0) {
content = new byte[contentLen];
in.readBytes(content);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void deserializeContent(InvokeContext invokeContext) throws Deserializati
&& this.getCustomSerializer().deserializeContent(this, invokeContext)) {
return;
}
if (this.getContent() != null) {
if (this.getContent() != null && this.getContentLength() > 0) {
this.setResponseObject(SerializerManager.getSerializer(this.getSerializer())
.deserialize(this.getContent(), this.responseClass));
}
Expand Down