(The site was temporarily down for maintenance when I tried to post this a couple of hours ago, so doing it again now.)
I agree completely.
My snippet is a quick hotfix, the first thought that crossed my mind (since
I was somewhat in a hurry).
If the SSL engine provides the maximum packet size, it definitely should be
used here instead.
I too do not see any reason to keep the old expansion code (as suggested in
DIRMINA-914) once the packet buffer size is used - so go ahead and replace
it with the new one. Of course, I did not study the issue very thoroughly,
so no guarantee.