Hello,
Sorry for the previous mail ...
I have a NIO connector with an asynchronous servlet with its write listener
(working in both tomcat 8.5 and tomcat 10.1.20).
@Override
public void onWritePossible() throws IOException {
if (this.isFirst) {
this.os = this.asyncContext.getResponse().getOutputStream();
this.startIdx = 0;
this.endIdx = WRITE_BUFFER_SIZE;
}
while (this.startIdx < this.endIdx && this.os.isReady()) {
this.os.write(this.response, this.startIdx, this.endIdx - this.startIdx);
this.startIdx = this.endIdx;
this.endIdx += WRITE_BUFFER_SIZE;
if (this.endIdx > this.response.length) this.endIdx = this.response.length;
}
if (this.startIdx == this.endIdx) {
this.ac.complete();
}
}
Only when the response to return is bigger than 32K then:
1. Writing the response in chunks of WRITE_BUFFER_SIZE = 32K, sometimes our
client receives the response in wrong order (complete, all bytes written, but
in different order).
2. Setting a WRITE_BUFFER_SIZE = 8K seems to fix this issue.
But it's weird, this is only happening in this client, we have other
installations returning responses of megabytes with no issues.
So just a couple of questions:
1. Do you think the implementation of the onWritePossible method above is
correct?
2. Is it worth to provide a buffered implementation of the ServletOuputStream
to write the response?
Thanks,
Joan.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]