WebFlux - transaction has status code 200 where it should be 500
See original GitHub issue- spring version 2.2.6 webflux, netty
@Operation(
summary = "상품 이미지 검색", description = "상품 이미지 검색 api", responses = {
@ApiResponse(responseCode = "200", description = "상품 이미지 검색 성공", content = @Content(schema = @Schema(implementation = GoodsDTOV1.ImageResponse.class))),
@ApiResponse(responseCode = "404", description = "상품 이미지 검색 실패", content = @Content(schema = @Schema(implementation = GoodsDTOV1.ImageResponse.class)))
}
)
@GetMapping("/goods")
@ReactorCacheables(cacheNames = CacheNameConstant.GOODS_IMAGE_LIST, key = "getCacheKey(#method)")
public Mono<ResponseDTOV2> getGoodsList(@ParameterObject @ModelAttribute @Valid GoodsDTOV1.Search goods) {
return goodsService.getGoodsList(goods.getUrl(), ImageSearchTypeEnum.getValue(goods.getImageSearchType()))
.flatMap(goodsImageVO -> {
final GoodsDTOV1.ImageResponse imageResponse = goodsMapStruct.toDTO(goodsImageVO);
if (1 == 1) {
throw new RuntimeException();
}
return Mono.just(
ResponseDTOV2.builder().data(imageResponse).build()
);
});
}
Obviously a status 500 internal server error occurred.
In elastic-apm it comes out as 200
@Operation(
summary = "상품 이미지 검색", description = "상품 이미지 검색 api", responses = {
@ApiResponse(responseCode = "200", description = "상품 이미지 검색 성공", content = @Content(schema = @Schema(implementation = GoodsDTOV1.ImageResponse.class))),
@ApiResponse(responseCode = "404", description = "상품 이미지 검색 실패", content = @Content(schema = @Schema(implementation = GoodsDTOV1.ImageResponse.class)))
}
)
@GetMapping("/goods")
@ReactorCacheables(cacheNames = CacheNameConstant.GOODS_IMAGE_LIST, key = "getCacheKey(#method)")
public Mono<ResponseDTOV2> getGoodsList(@ParameterObject @ModelAttribute @Valid GoodsDTOV1.Search goods) {
if (1 == 1) {
throw new RuntimeException();
}
return goodsService.getGoodsList(goods.getUrl(), ImageSearchTypeEnum.getValue(goods.getImageSearchType()))
.flatMap(goodsImageVO -> {
final GoodsDTOV1.ImageResponse imageResponse = goodsMapStruct.toDTO(goodsImageVO);
return Mono.just(
ResponseDTOV2.builder().data(imageResponse).build()
);
});
}
If the exception is outside of mono, it is exposed normally, but if an error occurs inside mono, it does not work properly.
404 is normal
Issue Analytics
- State:
- Created 2 years ago
- Comments:30 (12 by maintainers)
Top Results From Across the Web
Status expected:<200> but was:<404> in spring test
Following is what i did in spring mvc which worked fine (explained as unable to find direct reference) Controller class ...
Read more >[Java] High Mongo time and error rates on Spring Webflux and ...
Currently, I'm facing two problems. One is high mongo time and the other is errors rates. On the mongo issue, the mongo DB...
Read more >How to Get Response Body When Testing the Status Code in ...
In this tutorial, we'll look at how to access the status code and response body returned from a REST request using WebFlux's WebClient....
Read more >Spring Boot performance battle: blocking vs non-blocking vs ...
The default thread pool is 200 that was why we have 200 requests/sec for 1000ms response time. But we needed an elastic service:...
Read more >Spring Data R2DBC Transaction - Vinsguru
A database transaction is a unit of work, which could be made of up of 1 or more SQL statements, which is either...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh nevermind - It looks like 1.26.0 was just released and it seems to resolve the issue I was facing. Thanks!
okay @SylvainJuge i will try soon