title: Can't enable RequestRateLimiter filter in Spring Cloud Gateway
body: <p>I am trying to enable RequestRateLimiter in Spring Cloud Gateway. I havr configured other filters, even a custom one, but when I add this to one of my routes:</p>
  
  <pre><code> filters:
      - StripPrefix=1
      - name: RequestRateLimiter
        args:
          redis-rate-limiter.replenishRate: 2
          redis-rate-limiter.burstCapacity: 3
  </code></pre>
  
  <p>Spring Boot version:
  2.1.6.RELEASE
  Spring Cloud version:
  Greenwich.SR2</p>
  
  <p>Application code is very basic. Just has a OAuth filter in another class which I have disabled to make sure it won't be the cause of the issue:</p>
  
  <pre><code>@Configuration
  @SpringBootApplication
  @ComponentScan({ "com.skios.ms.gateway" })
  @EnableDiscoveryClient
  public class GatewayApplication implements ApplicationListener&lt;ApplicationReadyEvent&gt; {
      private Logger logger = LoggerFactory.getLogger(GatewayApplication.class);
  
      @Autowired
      private Environment environment;
  
      public static Map&lt;String, String&gt; versions;
  
      public static void main(String[] args) {
          SpringApplication app = new SpringApplication(GatewayApplication.class);
          SimpleCommandLinePropertySource source = new SimpleCommandLinePropertySource(args);
          if (!source.containsProperty("spring.profiles.active") &amp;&amp; !System.getenv().containsKey("SPRING_PROFILES_ACTIVE"))
              app.setAdditionalProfiles("local");
          app.setWebApplicationType(WebApplicationType.REACTIVE);
          app.run(args);
      }
  
      @Override
      public void onApplicationEvent(ApplicationReadyEvent event) {
          logger.info("Loaded profile: {}", Arrays.toString(environment.getActiveProfiles()));
      }
  
      @Bean
      @Primary
      public CorsConfiguration corsConfiguration(RoutePredicateHandlerMapping routePredicateHandlerMapping) {
          CorsConfiguration corsConfiguration = new CorsConfiguration().applyPermitDefaultValues();
          Arrays.asList(HttpMethod.OPTIONS, HttpMethod.PUT, HttpMethod.GET, HttpMethod.DELETE, HttpMethod.POST, HttpMethod.PATCH).forEach(m -&gt; corsConfiguration.addAllowedMethod(m));
          corsConfiguration.setAllowCredentials(true);
          corsConfiguration.setAllowedOrigins(Arrays.asList("*"));
          corsConfiguration.addAllowedHeader("*");
          routePredicateHandlerMapping.setCorsConfigurations(new HashMap&lt;String, CorsConfiguration&gt;() {
              {
                  put("/**", corsConfiguration);
              }
          });
  
          return corsConfiguration;
      }
  
      @Bean
      public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
          return http.csrf().disable().build();
      }
  }
  </code></pre>
  
  <p>I get this exception (Of course, if I remove the RequestRateLimiter filter and I just leave the StripPrefix entry, everything works ok. I have stripped down the code of the exception):</p>
  
  <pre><code>    2019-07-07 20:46:14.514 ERROR 1 --- [or-http-epoll-2] o.s.w.s.adapter.HttpWebHandlerAdapter    : [af6d0b2b] Error [java.lang.UnsupportedOperationException] for HTTP GET "/orion/v2/entities", but ServerHttpResponse already committed (403 FORBIDDEN)
      2019-07-07 20:46:14.525 ERROR 1 --- [or-http-epoll-2] r.n.http.server.HttpServerOperations     : [id: 0xaf6d0b2b, L:/172.30.41.45:8080 - R:/10.135.138.40:54598] Error starting response. Replying error status
  
      java.lang.UnsupportedOperationException: null
          at org.springframework.http.ReadOnlyHttpHeaders.set(ReadOnlyHttpHeaders.java:99) ~[spring-web-5.1.8.RELEASE.jar:5.1.8.RELEASE]
          at org.springframework.cloud.gateway.filter.factory.SetResponseHeaderGatewayFilterFactory.lambda$null$0(SetResponseHeaderGatewayFilterFactory.java:32) ~[spring-cloud-gateway-core-2.1.2.RELEASE.jar:2.1.2.RELEASE]
          at reactor.core.publisher.MonoRunnable.call(MonoRunnable.java:73) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoRunnable.call(MonoRunnable.java:32) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoCallableOnAssembly.call(MonoCallableOnAssembly.java:90) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:135) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:56) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:56) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.Mono.subscribe(Mono.java:3848) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoDoFinallyFuseable.subscribe(MonoDoFinallyFuseable.java:48) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.Mono.subscribe(Mono.java:3848) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
  [..]
  reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:56) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.Mono.subscribe(Mono.java:3848) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:56) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:70) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:56) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:61) ~[reactor-core-3.2.10.RELEASE.jar:3.2.10.RELEASE]
          at reactor.netty.http.server.HttpServerHandle.onStateChange(HttpServerHandle.java:64) ~[reactor-netty-0.8.9.RELEASE.jar:0.8.9.RELEASE]
          at reactor.netty.tcp.TcpServerBind$ChildObserver.onStateChange(TcpServerBind.java:226) ~[reactor-netty-0.8.9.RELEASE.jar:0.8.9.RELEASE]
          at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:442) ~[reactor-netty-0.8.9.RELEASE.jar:0.8.9.RELEASE]
          at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:91) ~[reactor-netty-0.8.9.RELEASE.jar:0.8.9.RELEASE]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:161) ~[reactor-netty-0.8.9.RELEASE.jar:0.8.9.RELEASE]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323) ~[netty-codec-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297) ~[netty-codec-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) ~[netty-transport-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:796) ~[netty-transport-native-epoll-4.1.36.Final-linux-x86_64.jar:4.1.36.Final]
          at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:432) ~[netty-transport-native-epoll-4.1.36.Final-linux-x86_64.jar:4.1.36.Final]
          at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:333) ~[netty-transport-native-epoll-4.1.36.Final-linux-x86_64.jar:4.1.36.Final]
          at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906) ~[netty-common-4.1.36.Final.jar:4.1.36.Final]
          at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.36.Final.jar:4.1.36.Final]
          at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
          Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
      Assembly trace from producer [reactor.core.publisher.MonoIgnoreThen] :
          reactor.core.publisher.Mono.then(Mono.java:4078)
          org.springframework.cloud.gateway.filter.factory.SetResponseHeaderGatewayFilterFactory.lambda$apply$1(SetResponseHeaderGatewayFilterFactory.java:31)
      Error has been observed by the following operator(s):
          |_  Mono.then ⇢ org.springframework.cloud.gateway.filter.factory.SetResponseHeaderGatewayFilterFactory.lambda$apply$1(SetResponseHeaderGatewayFilterFactory.java:31)
          |_  Mono.defer ⇢ org.springframework.cloud.gateway.handler.FilteringWebHandler$DefaultGatewayFilterChain.filter(FilteringWebHandler.java:113)
          |_  Mono.doOnSuccessOrError ⇢ org.springframework.cloud.gateway.filter.GatewayMetricsFilter.filter(GatewayMetricsFilter.java:60)
  
  [...]
  
  org.springframework.http.server.reactive.ReactorHttpHandlerAdapter.apply(ReactorHttpHandlerAdapter.java:66)
          |_  Mono.doOnSuccess ⇢ org.springframework.http.server.reactive.ReactorHttpHandlerAdapter.apply(ReactorHttpHandlerAdapter.java:67)
  </code></pre>