Skip to content

Commit

Permalink
support handle empty response content (#363)
Browse files Browse the repository at this point in the history
* fix code style

* support two way ssl validation

* support handle empty response and upgrade version to 1.6.11-SNAPSHOT

* format code

* bugfix: donot deserializeContent when contentLength == 0

---------

Co-authored-by: linxin <[email protected]>
  • Loading branch information
dbl-x and linxin authored Nov 27, 2024
1 parent 80bb0c9 commit 8bcdae6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
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

0 comments on commit 8bcdae6

Please sign in to comment.