[log] Protect against ref comparator errors like in IDEA-133194

(cherry picked from commit 0aae897677f7d6d6785e572abe0faa68dbeb5886)