backport fix LPS-29645 to current version

backporting
https://github.com/my3/liferay-portal/commit/b82e41722b30f85e9fb5b7b9715de09bfdecc665