title: @RequestScope not working when upgrading to spring-boot 2.5.6
body: <p>Once upgrading from spring boot 2.2.0.RELEASE to 2.5.6, web app doesn't start up.
  It gives no errors. But I see error in my mvc tests</p>
  <p>I inject the <code>HttpServletRequest</code> into the custom <code>HealthIndicator</code>. it stopped working after upgrade</p>
  <pre><code>@Component
  @RequestScope
  @Slf4j
  public class CacheHealthIndicator extends BaseHealthIndicator implements HealthIndicator {
  
      private static final String MESSAGE_KEY = &quot;cause&quot;;
      private static final String NOT_AVAILABLE = &quot;Cache is not available.&quot;;
  
      private final CacheService cacheService;
  
      public CacheHealthIndicator(final CacheService cacheService, final HttpServletRequest request) {
          super(request);
          this.cacheService = cacheService;
      }
  
      @Override
      public Health health() {
          try {
              if (cacheService.isAvailable()) {
                  log.info(&quot;Cache health check: UP. {}&quot;, getProbeType());
                  return Health.up().withDetail(MESSAGE_KEY, &quot;OK&quot;).build();
              }
          } catch (final Exception e) {
              log.error(&quot;Cache Health check is DOWN. Error: {}. {}&quot;, e.getMessage(), getProbeType());
              return Health.down().withDetail(MESSAGE_KEY, e.toString()).build();
          }
          log.error(&quot;Cache Health check is DOWN. {}: {}. {}&quot;, MESSAGE_KEY, NOT_AVAILABLE, getProbeType());
          return Health.down().withDetail(MESSAGE_KEY, NOT_AVAILABLE).build();
      }
  }
  
  public class BaseHealthIndicator {
  
      private static final String PROBE_TYPE = &quot;Probe-type&quot;;
  
      private final StringBuilder probeType;
  
      public BaseHealthIndicator(final HttpServletRequest request) {
          probeType = new StringBuilder();
          final Enumeration&lt;String&gt; headers = request.getHeaders(PROBE_TYPE);
          if (headers != null) {
              while (headers.hasMoreElements()) {
                  probeType.append(headers.nextElement());
              }
          }
      }
  
      public String getProbeType() {
          return probeType.toString();
      }
  }
  </code></pre>
  <p>This is the error I get:</p>
  <pre><code>java.lang.IllegalStateException: Failed to load ApplicationContext
  
      at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
      at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
      at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
      at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
      at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
      at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
      at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
      at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
      at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
      at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
      at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
      at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.support.ScopeNotActiveException: Error creating bean with name 'scopedTarget.cacheHealthIndicator': Scope 'request' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
  </code></pre>