diff --git a/core/lib/Drupal/Core/Path/PathValidator.php b/core/lib/Drupal/Core/Path/PathValidator.php
index f7efdb1..e09ee9f 100644
--- a/core/lib/Drupal/Core/Path/PathValidator.php
+++ b/core/lib/Drupal/Core/Path/PathValidator.php
@@ -151,24 +151,30 @@ protected function getPathAttributes($path, Request $request, $access_check) {
     else {
       $router = $this->accessAwareRouter;
     }
-
+    $request_context = $router->getContext();
     $path = $this->pathProcessor->processInbound('/' . $path, $request);
 
     try {
-      return $router->match($path);
+      $context = clone \Drupal::service('router.request_context');
+      $context->fromRequest($request);
+      $router->setContext($context);
+      $result = $router->match($path);
     }
     catch (ResourceNotFoundException $e) {
-      return FALSE;
+      $result = FALSE;
     }
     catch (ParamNotConvertedException $e) {
-      return FALSE;
+      $result = FALSE;
     }
     catch (AccessDeniedHttpException $e) {
-      return FALSE;
+      $result = FALSE;
     }
     catch (MethodNotAllowedException $e) {
-      return FALSE;
+      $result = FALSE;
     }
+
+    $router->setContext($request_context);
+    return $result;
   }
 
 }
