[2.7.x] NEXUS-6220: Backport to 2.7.x

Be smarter about connection reuse (backported from master to 2.7.x)

Commits:
9000d5ee7462ef6948323feda218592dedd18674
91e10a8ee912775e8479ad98a45a79d1f386f276
bc33bff36cfab6ab51adbf2e781ab0464dde70a4
bf31deb2afd84522e9a2206952b04b9b39000119

Original PR:
https://github.com/sonatype/nexus-oss/pull/315

CI
https://bamboo.zion.sonatype.com/browse/NX-OSSF22