|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -39,6 +39,9 @@ import java.util.concurrent.atomic.AtomicLong; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.function.Consumer; |
|
|
|
import java.util.function.Consumer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import io.netty.util.IllegalReferenceCountException; |
|
|
|
|
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
|
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
import org.reactivestreams.Publisher; |
|
|
|
import org.reactivestreams.Publisher; |
|
|
|
import org.reactivestreams.Subscription; |
|
|
|
import org.reactivestreams.Subscription; |
|
|
|
import reactor.core.publisher.BaseSubscriber; |
|
|
|
import reactor.core.publisher.BaseSubscriber; |
|
|
|
@ -60,6 +63,8 @@ import org.springframework.util.Assert; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public abstract class DataBufferUtils { |
|
|
|
public abstract class DataBufferUtils { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final static Log logger = LogFactory.getLog(DataBufferUtils.class); |
|
|
|
|
|
|
|
|
|
|
|
private static final Consumer<DataBuffer> RELEASE_CONSUMER = DataBufferUtils::release; |
|
|
|
private static final Consumer<DataBuffer> RELEASE_CONSUMER = DataBufferUtils::release; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -494,7 +499,15 @@ public abstract class DataBufferUtils { |
|
|
|
if (dataBuffer instanceof PooledDataBuffer) { |
|
|
|
if (dataBuffer instanceof PooledDataBuffer) { |
|
|
|
PooledDataBuffer pooledDataBuffer = (PooledDataBuffer) dataBuffer; |
|
|
|
PooledDataBuffer pooledDataBuffer = (PooledDataBuffer) dataBuffer; |
|
|
|
if (pooledDataBuffer.isAllocated()) { |
|
|
|
if (pooledDataBuffer.isAllocated()) { |
|
|
|
return pooledDataBuffer.release(); |
|
|
|
try { |
|
|
|
|
|
|
|
return pooledDataBuffer.release(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (IllegalReferenceCountException ex) { |
|
|
|
|
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
|
|
|
|
logger.debug("RefCount already at 0", ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
@ -523,7 +536,6 @@ public abstract class DataBufferUtils { |
|
|
|
* @return a buffer that is composed from the {@code dataBuffers} argument |
|
|
|
* @return a buffer that is composed from the {@code dataBuffers} argument |
|
|
|
* @since 5.0.3 |
|
|
|
* @since 5.0.3 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
|
|
|
public static Mono<DataBuffer> join(Publisher<? extends DataBuffer> dataBuffers) { |
|
|
|
public static Mono<DataBuffer> join(Publisher<? extends DataBuffer> dataBuffers) { |
|
|
|
return join(dataBuffers, -1); |
|
|
|
return join(dataBuffers, -1); |
|
|
|
} |
|
|
|
} |
|
|
|
|