diff --git a/lib/private/ServerContainer.php b/lib/private/ServerContainer.php
index 40e261df4d6991bc4f322286d0cd639482e128ee..e1447d2f06bda1a2451e12bae02c57799c71b0e7 100644
--- a/lib/private/ServerContainer.php
+++ b/lib/private/ServerContainer.php
@@ -107,6 +107,10 @@ class ServerContainer extends SimpleContainer {
 	public function query($name) {
 		$name = $this->sanitizeName($name);
 
+		if (isset($this[$name])) {
+			return $this[$name];
+		}
+
 		// In case the service starts with OCA\ we try to find the service in
 		// the apps container first.
 		if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) {