backported the fix for RavenDB_1379 from 3.0 to 2.5