Skip to content

Commit dfc7540

Browse files
committed
Add generic type bounds to DataBufferUtils methods
Closes gh-23459
1 parent 48934cb commit dfc7540

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public static Flux<DataBuffer> write(Publisher<DataBuffer> source, AsynchronousF
320320
* writing errors and the completion signal
321321
*/
322322
public static Flux<DataBuffer> write(
323-
Publisher<DataBuffer> source, AsynchronousFileChannel channel, long position) {
323+
Publisher<? extends DataBuffer> source, AsynchronousFileChannel channel, long position) {
324324

325325
Assert.notNull(source, "'source' must not be null");
326326
Assert.notNull(channel, "'channel' must not be null");
@@ -332,8 +332,19 @@ public static Flux<DataBuffer> write(
332332
sink.onDispose(handler);
333333
flux.subscribe(handler);
334334
});
335+
336+
337+
}
338+
339+
public void handle() {
340+
Number n = 5;
341+
inspect(n);
335342
}
336343

344+
public <U extends Number> void inspect(U u){
345+
}
346+
347+
337348
/**
338349
* Write the given stream of {@link DataBuffer DataBuffers} to the given
339350
* file {@link Path}. The optional {@code options} parameter specifies
@@ -409,7 +420,7 @@ static void closeChannel(@Nullable Channel channel) {
409420
* @param maxByteCount the maximum byte count
410421
* @return a flux whose maximum byte count is {@code maxByteCount}
411422
*/
412-
public static Flux<DataBuffer> takeUntilByteCount(Publisher<DataBuffer> publisher, long maxByteCount) {
423+
public static Flux<DataBuffer> takeUntilByteCount(Publisher<? extends DataBuffer> publisher, long maxByteCount) {
413424
Assert.notNull(publisher, "Publisher must not be null");
414425
Assert.isTrue(maxByteCount >= 0, "'maxByteCount' must be a positive number");
415426

@@ -440,7 +451,7 @@ public static Flux<DataBuffer> takeUntilByteCount(Publisher<DataBuffer> publishe
440451
* @param maxByteCount the maximum byte count
441452
* @return a flux with the remaining part of the given publisher
442453
*/
443-
public static Flux<DataBuffer> skipUntilByteCount(Publisher<DataBuffer> publisher, long maxByteCount) {
454+
public static Flux<DataBuffer> skipUntilByteCount(Publisher<? extends DataBuffer> publisher, long maxByteCount) {
444455
Assert.notNull(publisher, "Publisher must not be null");
445456
Assert.isTrue(maxByteCount >= 0, "'maxByteCount' must be a positive number");
446457

@@ -520,7 +531,8 @@ public static Consumer<DataBuffer> releaseConsumer() {
520531
* @return a buffer that is composed from the {@code dataBuffers} argument
521532
* @since 5.0.3
522533
*/
523-
public static Mono<DataBuffer> join(Publisher<DataBuffer> dataBuffers) {
534+
@SuppressWarnings("unchecked")
535+
public static Mono<DataBuffer> join(Publisher<? extends DataBuffer> dataBuffers) {
524536
Assert.notNull(dataBuffers, "'dataBuffers' must not be null");
525537

526538
if (dataBuffers instanceof Mono) {

0 commit comments

Comments
 (0)