From dfc754010648331e3aeb658631c238c0e92353dd Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 4 Sep 2019 12:13:51 +0100 Subject: [PATCH] Add generic type bounds to DataBufferUtils methods Closes gh-23459 --- .../core/io/buffer/DataBufferUtils.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java index 62df399aa7..15da683dbe 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java @@ -320,7 +320,7 @@ public abstract class DataBufferUtils { * writing errors and the completion signal */ public static Flux write( - Publisher source, AsynchronousFileChannel channel, long position) { + Publisher source, AsynchronousFileChannel channel, long position) { Assert.notNull(source, "'source' must not be null"); Assert.notNull(channel, "'channel' must not be null"); @@ -332,8 +332,19 @@ public abstract class DataBufferUtils { sink.onDispose(handler); flux.subscribe(handler); }); + + } + public void handle() { + Number n = 5; + inspect(n); + } + + public void inspect(U u){ + } + + /** * Write the given stream of {@link DataBuffer DataBuffers} to the given * file {@link Path}. The optional {@code options} parameter specifies @@ -409,7 +420,7 @@ public abstract class DataBufferUtils { * @param maxByteCount the maximum byte count * @return a flux whose maximum byte count is {@code maxByteCount} */ - public static Flux takeUntilByteCount(Publisher publisher, long maxByteCount) { + public static Flux takeUntilByteCount(Publisher publisher, long maxByteCount) { Assert.notNull(publisher, "Publisher must not be null"); Assert.isTrue(maxByteCount >= 0, "'maxByteCount' must be a positive number"); @@ -440,7 +451,7 @@ public abstract class DataBufferUtils { * @param maxByteCount the maximum byte count * @return a flux with the remaining part of the given publisher */ - public static Flux skipUntilByteCount(Publisher publisher, long maxByteCount) { + public static Flux skipUntilByteCount(Publisher publisher, long maxByteCount) { Assert.notNull(publisher, "Publisher must not be null"); Assert.isTrue(maxByteCount >= 0, "'maxByteCount' must be a positive number"); @@ -520,7 +531,8 @@ public abstract class DataBufferUtils { * @return a buffer that is composed from the {@code dataBuffers} argument * @since 5.0.3 */ - public static Mono join(Publisher dataBuffers) { + @SuppressWarnings("unchecked") + public static Mono join(Publisher dataBuffers) { Assert.notNull(dataBuffers, "'dataBuffers' must not be null"); if (dataBuffers instanceof Mono) {