diff --git a/lib/Doctrine/MongoDB/Query/Query.php b/lib/Doctrine/MongoDB/Query/Query.php index b6edf4a4..7bfd30a1 100644 --- a/lib/Doctrine/MongoDB/Query/Query.php +++ b/lib/Doctrine/MongoDB/Query/Query.php @@ -481,17 +481,10 @@ private function withReadPreference($object, \Closure $closure) $object->setReadPreference($this->query['readPreference'], $this->query['readPreferenceTags']); try { - $result = $closure(); - } catch (\Exception $e) { - } - - $prevTags = ! empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : null; - $object->setReadPreference($prevReadPref['type'], $prevTags); - - if (isset($e)) { - throw $e; + return $closure(); + } finally { + $prevTags = ! empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : []; + $object->setReadPreference($prevReadPref['type'], $prevTags); } - - return $result; } }