-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behaviour when using repository saveAll() in WebFilter with response body #857
Comments
The difference seems to be the |
Thank you for the quick response, but if I change it to a scalar or for a fluxiterable subscription it works as expected. That is why I thought that the repository's save/saveAll method handles something differently when there's a body in the response. With Mono.just("String"):
With Flux.fromIterable(list):
|
I have overcome this problem with a different approach using the @Component
@Order(Ordered.LOWEST_PRECEDENCE)
@Slf4j
public class LogWebFilter implements WebFilter {
@Autowired
private UserOperationLogRepository userOperationLogRepository;
@NonNull
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
exchange.getResponse().beforeCommit(() -> Mono.deferContextual(ctx -> {
var list = new ArrayList<UserOperationLog>();
var userOperationLog = new UserOperationLog();
userOperationLog.setAction((short) 1);
userOperationLog.setPayload("payload");
userOperationLog.setResource("Client");
userOperationLog.setRowId(1L);
userOperationLog.setCreatedAt(OffsetDateTime.now());
userOperationLog.setUserId(1L);
list.add(userOperationLog);
return userOperationLogRepository.saveAll(list).collectList().then();
}));
return chain
.filter(exchange);
}
} |
Hi,
I would like to call a repository saveAll method in a WebFilter class, but when I return with a body populated ServerResponse the saveAll doesn't save anything in the DB. Returning without a body, the data is saved in the DB.
Here are the sources that i use.
Router with handlers:
Webfilter:
The bean:
Reactive stream signal logs without response body:
Reactive stream signal logs with response body:
The text was updated successfully, but these errors were encountered: