You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "sick-cat (via GitHub)" <gi...@apache.org> on 2023/08/14 04:13:22 UTC
[GitHub] [dubbo] sick-cat opened a new issue, #12891: rest 接口响应内容大于1kb时触发分块传输,导致报错
sick-cat opened a new issue, #12891:
URL: https://github.com/apache/dubbo/issues/12891
<!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy -->
- [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
### Environment
* Dubbo version: 3.2.5
* Java version: 1.8
### Steps to reproduce this issue
1. 使用rest协议暴露一个接口,响应内容大于 1kb
2. 服务启动后,访问该接口即可触发。
### Actual Behavior
<!-- What actually happens? -->
实际响应内容会追加报错信息
```
dubbo rest invoke Internal error, message is null ,and exception type is : class java.lang.IllegalStateException , stacktrace is:
at org.apache.dubbo.rpc.protocol.rest.netty.ChunkOutputStream.reset(ChunkOutputStream.java:53)
at org.apache.dubbo.rpc.protocol.rest.extension.resteasy.ResteasyContext.restOutputStream(ResteasyContext.java:176)
at org.apache.dubbo.rpc.protocol.rest.extension.resteasy.filter.ResteasyResponseContainerFilterAdapter.filter(ResteasyResponseContainerFilterAdapter.java:62)
at org.apache.dubbo.rpc.protocol.rest.handler.NettyHttpHandler.executeFilters(NettyHttpHandler.java:137)
at org.apache.dubbo.rpc.protocol.rest.handler.NettyHttpHandler.handle(NettyHttpHandler.java:107)
at org.apache.dubbo.rpc.protocol.rest.netty.RestHttpRequestDecoder.lambda$decode$0(RestHttpRequestDecoder.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.dubbo.common.threadlocal.InternalRunnable.run(InternalRunnable.java:41)
at java.lang.Thread.run(Thread.java:748)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] CrazyHZM commented on issue #12891: rest 接口响应内容大于1kb时触发分块传输,导致报错
Posted by "CrazyHZM (via GitHub)" <gi...@apache.org>.
CrazyHZM commented on issue #12891:
URL: https://github.com/apache/dubbo/issues/12891#issuecomment-1676647801
@suncairong163 PTAL
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] CrazyHZM closed issue #12891: rest 接口响应内容大于1kb时触发分块传输,导致报错
Posted by "CrazyHZM (via GitHub)" <gi...@apache.org>.
CrazyHZM closed issue #12891: rest 接口响应内容大于1kb时触发分块传输,导致报错
URL: https://github.com/apache/dubbo/issues/12891
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo] sick-cat commented on issue #12891: rest 接口响应内容大于1kb时触发分块传输,导致报错
Posted by "sick-cat (via GitHub)" <gi...@apache.org>.
sick-cat commented on issue #12891:
URL: https://github.com/apache/dubbo/issues/12891#issuecomment-1676648278
org.apache.dubbo.rpc.protocol.rest.netty.NettyHttpResponse中通过一下方式创建outputstream
```java
os = new ChunkOutputStream(this, ctx, 1000);
```
org.apache.dubbo.rpc.protocol.rest.netty.ChunkOutputStream 会分块处理长度超过1000的响应内容。
```java
public void write(byte[] b, int off, int len) throws IOException {
int dataLengthLeftToWrite = len;
int dataToWriteOffset = off;
int spaceLeftInCurrentChunk;
while ((spaceLeftInCurrentChunk = buffer.maxWritableBytes()) < dataLengthLeftToWrite) {
buffer.writeBytes(b, dataToWriteOffset, spaceLeftInCurrentChunk);
dataToWriteOffset = dataToWriteOffset + spaceLeftInCurrentChunk;
dataLengthLeftToWrite = dataLengthLeftToWrite - spaceLeftInCurrentChunk;
flush();
}
if (dataLengthLeftToWrite > 0) {
buffer.writeBytes(b, dataToWriteOffset, dataLengthLeftToWrite);
}
}
```
org.apache.dubbo.rpc.protocol.rest.extension.resteasy.filter.ResteasyResponseContainerFilterAdapter会在 `restOutputStream(response);` 时触发异常
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org