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

Original PR
https://github.com/sonatype/nexus-oss/pull/352

Issue
https://issues.sonatype.org/browse/NEXUS-6278