reactor-core/src/main/java/reactor/core/publisher/Operators.java
public static final Context enableOnDiscard(@Nullable Context target, Consumer<?> discardConsumer) {
		Objects.requireNonNull(discardConsumer, "discardConsumer must be provided");
		if (target == null) {
			return Context.of(Hooks.KEY_ON_DISCARD, discardConsumer);
		}
		return target.put(Hooks.KEY_ON_DISCARD, discardConsumer);
	}
public static final Context enableOnDiscard(@Nullable Context target, Consumer<?> discardConsumer) {
		Objects.requireNonNull(discardConsumer, "discardConsumer must be provided");
		if (target == null) {
			return Context.of(Hooks.KEY_ON_DISCARD, discardConsumer);
		}
		return target.put(Hooks.KEY_ON_DISCARD, discardConsumer);
	}
public static final Context enableOnDiscard ( @ Nullable Context target , Consumer < ? > discardConsumer ) { Objects . requireNonNull ( discardConsumer , "discardConsumer must be provided" ) ; if ( target == null ) { return Context . of ( Hooks . KEY_ON_DISCARD , discardConsumer ) ; } return target . put ( Hooks . KEY_ON_DISCARD , discardConsumer ) ; }
Utility method to activate the onDiscard feature (see {@link Flux#doOnDiscard(Class, Consumer)})
in a target {@link Context}. Prefer using the {@link Flux} API, and reserve this for
testing purposes.

@param target the original {@link Context}
@param discardConsumer the consumer that will be used to cleanup discarded elements
@return a new {@link Context} that holds (potentially combined) cleanup {@link Consumer}
Utility method to activate the onDiscard feature ( see { @link Flux#doOnDiscard ( Class Consumer ) } ) in a target { @link Context } . Prefer using the { @link Flux } API and reserve this for testing purposes .