简体   繁体   中英

Spring-Webflux : Flatmap is making list empty

I am using reactive programming with Webflux to write my REST api. I have response object below like this:

class Account
{
  private Customer customer;
  private List<Accounts> accountList;

}

I am setting customer and accountList using getters and setters. I can see both populated correctly, but my final response is always being returned with the right "Customer", but it is an empty account list even though I can see the data in Account List.

return request
            .bodyToMono(PersonRequest.class)
            .doOnNext { logger.info("Request : $it") }
            .flatMap(validateRequest(it))
            .flatMap(personService::getPerson)
            .doOnNext (logger.info("Final Response : $it"))
           .flatMap(ServerResponse.ok().contentType(MediaType.APPLICATION_JSON)::bodyValue);

What am I doing wrong here? I can see "Final Response" log printing correctly but, after that I see an empty list in my JSON response.

这是由于我的 kotlin 数据类中的“私有变量”而发生的。删除私有对我有用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM