-1

I wonder that why type of state supplier in Flux.generate in spring reactor is a Callable not a Supplier? Is it because of preventing of blocking?

  • why should it be supplier, please motivate – Toerktumlare Apr 02 '20 at 13:00
  • Because its responsibility is to produce an initial value for state – Farshad Falaki Apr 02 '20 at 14:45
  • Yes it’s responsibility is to produce an inital value, still you havn’t motivated why a supplier interface would better suited then the callable? Are you basing your claim purly on the naming of the interface? – Toerktumlare Apr 02 '20 at 19:01
  • Then what was the reason for following inFlux class... public static Flux error(Supplier extends Throwable> errorSupplier) Here can't it be a Callable instead of Supplier? – Farshad Falaki Apr 04 '20 at 13:05
  • It can, yes, but you havn’t motivated WHY you think it should be one or the other. As someone pointed out, and was going to be my point after i heard your argument (which consists of purely of ”it can be like this, then it should be like that”) – Toerktumlare Apr 04 '20 at 14:16
  • The difference is that one of the interface can throw a checked exception, the other can’t. Then WHY they have chosen one or the mist be because of this reason. Just because one thing CAN be replaced by another thing doesn’t mean it is right. All we have mentioned here cousld easy be looked up by googling the java docs – Toerktumlare Apr 04 '20 at 14:18

1 Answers1

1

Callable can throw checked Exceptions, supplier cannot.

Adam Bickford
  • 1,216
  • 12
  • 14