Skip to content

Commit

Permalink
Fix turms request handler may use recycled buffers in the request #1416
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesChenX committed Mar 18, 2024
1 parent 1f89a07 commit 296afae
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ private Mono<ServiceResponse> dispatch0(TracingContext context, ServiceRequest s
null,
(TurmsRequest) request));
}
// Note that though we have already converted "turmsRequestBuffer"
// to the TurmsRequest instance, it seems like that we could release the buffer.
// But it will make trouble if the TurmsRequest instance declares bytes parameters
// because we use NioByteString to serve bytes parameters for better performance (direct
// buffer),
// while these NioByteString instances are based on this buffer.
// So we need to ensure the buffer is retained until we finish the workflow.
turmsRequestBuffer.retain();
return clientRequestMono.flatMap(lastClientRequest -> {
// 3. Validate ClientRequest
TurmsRequest lastRequest = lastClientRequest.turmsRequest();
Expand Down Expand Up @@ -361,7 +369,8 @@ private Mono<ServiceResponse> dispatch0(TracingContext context, ServiceRequest s
}
return response;
});
});
})
.doFinally(signal -> turmsRequestBuffer.release());
}

private Mono<Void> notifyRelatedUsersOfAction(
Expand Down

1 comment on commit 296afae

@zhaieryuan
Copy link

Choose a reason for hiding this comment

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

我按照您的修改方式调整了自己这边的代码,重新发起本地自测,还是出现乱码。好像这个调整并没有生效。

image

image

Please sign in to comment.