LPS-51028

Previous pull request https://github.com/rotty3000/liferay-portal/pull/658 failed for reason noted by @bejondshao (compilation error). After discussing it more, found a better fix, which was re-evaluated in https://github.com/bejondshao/liferay-portal/pull/8