Skip to content

Commit

Permalink
[DI] use try-finally for container
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobion committed Nov 26, 2015
1 parent 5183c88 commit 1ab7316
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Symfony/Component/DependencyInjection/Container.php
Expand Up @@ -272,17 +272,13 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
try {
$service = $this->$method();
} catch (\Exception $e) {
unset($this->loading[$id]);

if (array_key_exists($id, $this->services)) {
unset($this->services[$id]);
}
unset($this->services[$id]);

throw $e;
} finally {
unset($this->loading[$id]);
}

unset($this->loading[$id]);

return $service;
}
}
Expand Down

0 comments on commit 1ab7316

Please sign in to comment.