JDK 21 - Compliance Client's method handlers not receiving the entire request body #1519
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
We are trying to include testing for JDK 21 and our tests are flaky for the Compliance client. We believe the change is behavior is because of some internal JDK changes updated how the HttpRequests are sent over the network.
In JDK 17 and prior, the internal code had a byte buffer of ~8k bytes but the new changes start the capacity at 512 bytes. We think that this change made it so that it now takes multiple "writes" over the stream to send data over (i.e. it used to be able to be sent in one "write", but now takes 2+ "writes")
We believe that the golang io.Reader's Read() call does not block until all the "writes" have finished. Specifically this line:
gapic-showcase/server/genrest/compliance.go
Line 57 in f0e32bc
Environment details
Logs from Gapic Showcase Server
Error:
2024/07/01 17:05:20 error reading body params '*': proto: syntax error (line 1:513): invalid value
The Content-Length header says there are 514 bytes, but the reader only reports that 512 bytes are read.
The logs above are from this updated snippet in th showcase server:
Reproducer
Compliance ITs: https://github.com/googleapis/sdk-platform-java/blob/308aeafc9f04795d2e1df8206c84689b11c4323a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITHttpAnnotation.java#L123-L142
Run with JDK 21
Possible Solution
Update the clients to use
io.ReadAll(r.body)
when reading the request body.We have made this change locally and ran the Java Compliance ITs 1000x. We do not see this flaky test anymore and have a strong suspicion that this should fix it.
The text was updated successfully, but these errors were encountered: