2
Spring Cloud Gateway global filter throwing **Only one connection receive subscriber allowed.** when logging response from getting exchange.

Getting response from ServerWebExchange

Connection connection = exchange.getAttribute(CLIENT_RESPONSE_CONN_ATTR); 

After getting connection object to get NettyDataBuffer

    Flux<NettyDataBuffer> bodyNettyDataBuffer = connection.inbound().receive().retain().map(factory::wrap);

Then Subscriber to log request and it is failing here

bodyNettyDataBuffer.subscribe(buffer -> {

Initializing byte array

                byte[] dst = new byte[buffer.capacity()];

slice to buffer to get byter array value

                buffer.getNativeBuffer().slice().getBytes(0, dst);

converting into string and logging

                LOGGER.info("Response Body:{}", new String(dst));
            });
4

0 回答 0