Hello. I really want to open a discussion about the default registration of the OSIV/OEMIV web interceptors. The official issue #7107 has been opened since SB 1.x (9 years ago). In my experience this default behaviour has cause more harm than good. Over the years I have encountered multiple issues (connection pool starvation, memory leaks (from the bug lifetime of the session)) and so on..

Further the property name by itself is not really descriptive of what it does. It applies only foe the web layer. Making the same piece of code to behave differently based on where it is used.

For simplicity lets consider that we have an entity that has a one to many relation (lazy).Now lets look at the following code example:

public class Parent {

  @OneToMany
  Set<Child> children
}

@Component
public class PersonFacade {

    public ParentDto getParentById(long id) {
        var parent = parentRepository.findById(id);
        return parentMapper.map(parent); // parent.getChildren() is called during mapping
    }
}

Considering that I have the above piece of code, I would like to expose this both as an http endpoint and an async endpoint (e.g. spring cloud stream)

The following code will work fine:

@RestController
class PersonController {
  PersonDto getById(@PathVariable long id) {
    return personFacade.getParentById(id);
  }
}

While this Spring Cloud Stream function definition will fail with LazyInitializationException

@Configuration
class FunctionsConfig {

  @Bean
  Function<EventX, EventXResponse> someName(PersonFacade personFacade) {
    return ev -> new EventXResponse(personFacade.getParentById(ev.parentId()));
  }
}