He-Pin commented on code in PR #3019:
URL: https://github.com/apache/pekko/pull/3019#discussion_r3330294763
##########
stream/src/main/scala/org/apache/pekko/stream/impl/io/TlsGraphStage.scala:
##########
@@ -567,15 +563,13 @@ import pekko.util.ByteString
}
private def growTransportOutBuffer(): Unit = {
- val oldBuffer = transportOutBuffer
- val oldCapacity = oldBuffer.capacity()
+ val oldCapacity = transportOutBuffer.capacity()
if (oldCapacity > Int.MaxValue / 2)
throw new IllegalStateException(s"Cannot grow TLS transport output
buffer beyond $oldCapacity bytes")
- val bigger = acquireTransportBuffer(oldCapacity * 2)
+ val bigger = ByteBuffer.allocate(oldCapacity * 2)
transportOutBuffer.flip()
bigger.put(transportOutBuffer)
- releaseTransportBuffer(oldBuffer)
transportOutBuffer = bigger
}
Review Comment:
Good catch on the robustness point. With the current
`MaxApplicationRecordsPerEngineCall = 4` (a power of two) the doubling sequence
is Pā2Pā4P and lands exactly on the cap, so it doesn't overshoot in practice
today ā but you're right that it relies on that coincidence. Fixed in 97528ba:
clamp the doubled capacity to `maxTransportOutBufferSize` and fail fast if
growth is requested at/above the cap, so it stays correct for any cap value.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]