question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebFlux - transaction has status code 200 where it should be 500

See original GitHub issue
  1. 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

image

image

    @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()
                );
            });
    }

image

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 image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:30 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
jeff-lauterbach-bycommented, Sep 16, 2021

Oh nevermind - It looks like 1.26.0 was just released and it seems to resolve the issue I was facing. Thanks!

1reaction
sangkyunkim89commented, Aug 18, 2021

okay @SylvainJuge i will try soon

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found