From 8b4938ce4d08be31f159a1c375c3bda67397f3c4 Mon Sep 17 00:00:00 2001 From: Gyoungmin Kim Date: Sat, 26 Oct 2024 21:50:22 +0900 Subject: [PATCH] hotfix: remove problematic RequestBodyCachingFilter temporarily --- .../config/RequestBodyCachingFilter.java | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/photo-service/src/main/java/kr/mafoo/photo/config/RequestBodyCachingFilter.java b/photo-service/src/main/java/kr/mafoo/photo/config/RequestBodyCachingFilter.java index 5321ce6..1f8e31e 100644 --- a/photo-service/src/main/java/kr/mafoo/photo/config/RequestBodyCachingFilter.java +++ b/photo-service/src/main/java/kr/mafoo/photo/config/RequestBodyCachingFilter.java @@ -1,46 +1,46 @@ -package kr.mafoo.photo.config; - -import org.springframework.core.io.buffer.DataBuffer; -import org.springframework.core.io.buffer.DataBufferUtils; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.http.server.reactive.ServerHttpRequestDecorator; -import org.springframework.stereotype.Component; -import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.server.ServerWebExchangeDecorator; -import org.springframework.web.server.WebFilter; -import org.springframework.web.server.WebFilterChain; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -@Component -public class RequestBodyCachingFilter implements WebFilter { - - // TODO: 추후 정리 필요 - - @Override - public Mono filter(ServerWebExchange exchange, WebFilterChain chain) { - return DataBufferUtils.join(exchange.getRequest().getBody()) - .flatMap(dataBuffer -> { - byte[] bytes = new byte[dataBuffer.readableByteCount()]; - dataBuffer.read(bytes); - DataBufferUtils.release(dataBuffer); - - ServerHttpRequestDecorator decoratedRequest = new ServerHttpRequestDecorator(exchange.getRequest()) { - @Override - public Flux getBody() { - return Flux.just(exchange.getResponse().bufferFactory().wrap(bytes)); - } - }; - - ServerWebExchangeDecorator decoratedExchange = new ServerWebExchangeDecorator(exchange) { - @Override - public ServerHttpRequest getRequest() { - return decoratedRequest; - } - }; - - return chain.filter(decoratedExchange); - }); - } -} - +//package kr.mafoo.photo.config; +// +//import org.springframework.core.io.buffer.DataBuffer; +//import org.springframework.core.io.buffer.DataBufferUtils; +//import org.springframework.http.server.reactive.ServerHttpRequest; +//import org.springframework.http.server.reactive.ServerHttpRequestDecorator; +//import org.springframework.stereotype.Component; +//import org.springframework.web.server.ServerWebExchange; +//import org.springframework.web.server.ServerWebExchangeDecorator; +//import org.springframework.web.server.WebFilter; +//import org.springframework.web.server.WebFilterChain; +//import reactor.core.publisher.Flux; +//import reactor.core.publisher.Mono; +// +//@Component +//public class RequestBodyCachingFilter implements WebFilter { +// +// // TODO: 추후 정리 필요 +// +// @Override +// public Mono filter(ServerWebExchange exchange, WebFilterChain chain) { +// return DataBufferUtils.join(exchange.getRequest().getBody()) +// .flatMap(dataBuffer -> { +// byte[] bytes = new byte[dataBuffer.readableByteCount()]; +// dataBuffer.read(bytes); +// DataBufferUtils.release(dataBuffer); +// +// ServerHttpRequestDecorator decoratedRequest = new ServerHttpRequestDecorator(exchange.getRequest()) { +// @Override +// public Flux getBody() { +// return Flux.just(exchange.getResponse().bufferFactory().wrap(bytes)); +// } +// }; +// +// ServerWebExchangeDecorator decoratedExchange = new ServerWebExchangeDecorator(exchange) { +// @Override +// public ServerHttpRequest getRequest() { +// return decoratedRequest; +// } +// }; +// +// return chain.filter(decoratedExchange); +// }); +// } +//} +//