This commit is contained in:
Trustin Lee 2013-07-18 10:29:34 +09:00
parent 473af5c98e
commit 568166d554

View File

@ -229,14 +229,7 @@ final class ChannelOutboundBuffer {
final int size = unflushed.size(); final int size = unflushed.size();
try { try {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
safeRelease(messages[i]); safeRelease(messages[i], promises[i], cause);
ChannelPromise p = promises[i];
if (!(p instanceof VoidChannelPromise)) {
if (!p.tryFailure(cause)) {
logger.warn("Promise done already: {} - new exception is:", p, cause);
}
}
} }
} finally { } finally {
unflushed.recycle(); unflushed.recycle();
@ -279,12 +272,7 @@ final class ChannelOutboundBuffer {
final int size = current.size(); final int size = current.size();
try { try {
for (int i = currentMessageIndex; i < size; i++) { for (int i = currentMessageIndex; i < size; i++) {
safeRelease(messages[i]); safeRelease(messages[i], promises[i], cause);
ChannelPromise p = promises[i];
if (!(p instanceof VoidChannelPromise) && !p.tryFailure(cause)) {
logger.warn("Promise done already: {} - new exception is:", p, cause);
}
} }
} finally { } finally {
current.recycle(); current.recycle();
@ -296,11 +284,16 @@ final class ChannelOutboundBuffer {
} }
} }
private static void safeRelease(Object message) { private static void safeRelease(Object message, ChannelPromise promise, Throwable cause) {
try { try {
ReferenceCountUtil.release(message); ReferenceCountUtil.release(message);
} catch (Throwable t) { } catch (Throwable t) {
logger.warn("Failed to release a message.", t); logger.warn("Failed to release a message.", t);
} }
ChannelPromise p = promise;
if (!(p instanceof VoidChannelPromise) && !p.tryFailure(cause)) {
logger.warn("Promise done already: {} - new exception is:", p, cause);
}
} }
} }