/** * Sets the maximum message size allowed to be received on the channel. If not called, * defaults to 4 MiB. The default provides protection to clients who haven't considered the * possibility of receiving large messages while trying to be large enough to not be hit in normal * usage. * * <p>This method is advisory, and implementations may decide to not enforce this. Currently, * the only known transport to not enforce this is {@code InProcessTransport}. * * @param bytes the maximum number of bytes a single message can be. * @return this * @throws IllegalArgumentException if bytes is negative. * @since 1.1.0 */ public T maxInboundMessageSize(int bytes) { // intentional noop rather than throw, this method is only advisory. Preconditions.checkArgument(bytes >= 0, "bytes must be >= 0"); return thisT(); }
/** * Sets the maximum size of metadata allowed to be received. {@code Integer.MAX_VALUE} disables * the enforcement. The default is implementation-dependent, but is not generally less than 8 KiB * and may be unlimited. * * <p>This is cumulative size of the metadata. The precise calculation is * implementation-dependent, but implementations are encouraged to follow the calculation used for * <a href="http://httpwg.org/specs/rfc7540.html#rfc.section.6.5.2"> * HTTP/2's SETTINGS_MAX_HEADER_LIST_SIZE</a>. It sums the bytes from each entry's key and value, * plus 32 bytes of overhead per entry. * * @param bytes the maximum size of received metadata * @return this * @throws IllegalArgumentException if bytes is non-positive * @since 1.17.0 */ public T maxInboundMetadataSize(int bytes) { Preconditions.checkArgument(bytes > 0, "maxInboundMetadataSize must be > 0"); // intentional noop rather than throw, this method is only advisory. return thisT(); }
/** * Sets the maximum message size allowed to be received on the channel. If not called, * defaults to 4 MiB. The default provides protection to clients who haven't considered the * possibility of receiving large messages while trying to be large enough to not be hit in normal * usage. * * <p>This method is advisory, and implementations may decide to not enforce this. Currently, * the only known transport to not enforce this is {@code InProcessTransport}. * * @param max the maximum number of bytes a single message can be. * @throws IllegalArgumentException if max is negative. * @return this * @since 1.1.0 */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2307") public T maxInboundMessageSize(int max) { // intentional nop return thisT(); }