0
votes

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.

1
post validateRequest method - silentsudo
It’s just validating the incoming requests like fields are null or not. I don’t think it has to do anything with response.Final response log is good. But I believe last flatmap is making list empty. - Rocky4Ever
Post more of the code - Toerktumlare

1 Answers

0
votes

This is happenning due to "private var" inside my kotlin data classes.removing private worked for me.