port of fix RavenDB-2393 from 2.5