Fix for IDEA-81682, IDEA-107793?
(cherry picked from commit 99a2a14)