Skip to content

ReactiveBeforeSaveCallback doesn't work with generic type  #2822

@danielimre

Description

@danielimre

Before 3.0.5 the following was working for reactive before save callbacks:

public class MyBeforeSaveCallback<T> implements ReactiveBeforeSaveCallback<T> {
  @Override
  public Publisher<T> onBeforeSave(T entity, Document document, String collection) {...}
}

Then it could be defined as a bean like this:

@Bean
MyBeforeSaveCallback<Object> myCallback() {...}

This callback was found for arbitrary type.

In spring-data 3.0.5 this has stopped working. The callback is not found for any given type.

The change breaking this was most probably introduced with #2812

Workaround

The simplest workaround I found was just to eliminate the generic T and hardcode Object in MyBeforeSaveCallback like:

public class MyBeforeSaveCallback implements ReactiveBeforeSaveCallback<Object> {
  @Override
  public Publisher<Object> onBeforeSave(Object entity, Document document, String collection) {...}
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions