FELIX-3456 Apply final patch #7 introducing locking instead of Java synchronized to prevent deadlocks