consumidor doOnSuccessOrError de WebFilter no funciona cuando cabecera Content-Length es 0 [Primavera Nube de puerta de enlace]

votos
1

WebFilter de doOnSuccessOrErrory doAfterSuccessOrErrorconsumidores que no trabaja cuando la Content-Lengthcabecera es de 0.

Tengo un WebFilter de la siguiente manera:

@Bean
WebFilter webFilter() {
  return (exchange, chain) ->
      chain.filter(exchange)
          .doOnRequest(value -> {
            logger.error(webFilter +  doOnRequest);
          })
          .doOnSuccessOrError((aVoid, throwable) -> {
            logger.error(webFilter +  doOnSuccessOrError);
          })
          .doAfterSuccessOrError((aVoid, throwable) -> {
            logger.error(webFilter +  doAfterSuccessOrError);
          });
}

Las rutas de puerta de enlace todo el tráfico a una aplicación Tomcat mediante esta configuración:

@Bean
public RouteLocator routeLocator(RouteLocatorBuilder builder) {
  return builder.routes()
      .route(r -> r.path(/**)
          .uri(http://localhost:9001).filter(gatewayFilter()))
      .build();
}

Tengo estos tres puntos finales en aplicaciones Tomcat arranque de primavera:

@GetMapping(/redirect)
public ModelAndView redirectWithUsingRedirectPrefix(ModelMap model) {
  return new ModelAndView(redirect:http://google.com, model);
}

@GetMapping(/empty-response)
public ResponseEntity<Void> responseEntity() {
  return ResponseEntity.ok().build();
}

@GetMapping(/foo)
public ResponseEntity<String> string() {
  return ResponseEntity.ok(foo);
}

Solicitar a través de la puerta de entrada para /fooque funciona como se esperaba

[ctor-http-nio-2] GatewayConfiguration  : webFilter doOnRequest
[ctor-http-nio-2] GatewayConfiguration  : globalFilter doOnRequest
[ctor-http-nio-3] GatewayConfiguration  : gatewayFilter doOnRequest
[ctor-http-nio-3] GatewayConfiguration  : gatewayFilter doOnSuccessOrError
[ctor-http-nio-3] GatewayConfiguration  : globalFilter doOnSuccessOrError
[ctor-http-nio-3] GatewayConfiguration  : globalFilter doAfterSuccessOrError
[ctor-http-nio-3] GatewayConfiguration  : gatewayFilter doAfterSuccessOrError
[ctor-http-nio-2] GatewayConfiguration  : webFilter doOnSuccessOrError
[ctor-http-nio-2] GatewayConfiguration  : webFilter doAfterSuccessOrError

por /empty-response

[ctor-http-nio-4] GatewayConfiguration  : webFilter doOnRequest
[ctor-http-nio-4] GatewayConfiguration  : globalFilter doOnRequest
[ctor-http-nio-3] GatewayConfiguration  : gatewayFilter doOnRequest
[ctor-http-nio-3] GatewayConfiguration  : gatewayFilter doOnSuccessOrError
[ctor-http-nio-3] GatewayConfiguration  : globalFilter doOnSuccessOrError
[ctor-http-nio-3] GatewayConfiguration  : globalFilter doAfterSuccessOrError
[ctor-http-nio-3] GatewayConfiguration  : gatewayFilter doAfterSuccessOrError

GlobalFiltery GatewayFilterfunciona como se espera. Pero, como ves, webFilter doOnSuccessOrErrory webFilter doAfterSuccessOrErrorfaltan para /empty-response. Es igual para /redirectpunto final.

Puede utilizar https://github.com/hisener/sc-gateway-test para reproducirlo.

Publicado el 20/09/2018 a las 06:54
fuente por usuario
En otros idiomas...                            

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more