Class StreamValidationUtils


  • public class StreamValidationUtils
    extends Object
    Helper methods for stream validation.
    • Method Detail

      • checkRecursionDepth

        public static <T> boolean checkRecursionDepth​(int maxDepth,
                                                      BiConsumer<Long,​Throwable> onExceeded)
        Validation of Reactive Streams Specification for JVM rule 3.3.
        Subscription.request MUST place an upper bound on possible synchronous recursion between Publisher and Subscriber.
        Type Parameters:
        T - payload type of the subscriber
        Parameters:
        maxDepth - maximal expected recursion depth
        onExceeded - called if recursion is deeper than maxDepth, provided with actual depth and spec compliant exception.
        Returns:
        true if valid
        See Also:
        reactive-streams/reactive-streams-jvm#3.3
      • checkRequestParam

        public static boolean checkRequestParam​(long requestParam,
                                                Consumer<? super IllegalArgumentException> onExceeded)
        Validation of Reactive Streams Specification for JVM rule 3.9.
        While the Subscription is not cancelled, Subscription.request(long n) MUST signal onError with a IllegalArgumentException if the argument is less or equal to 0. The cause message SHOULD explain that non-positive request signals are illegal.
        Parameters:
        requestParam - number of requested items to be validated.
        onExceeded - called if request param invalid provided with spec compliant exception.
        Returns:
        true if requested parameter is valid
        See Also:
        reactive-streams/reactive-streams-jvm#3.9