From d0f3cd383d2bdda3b55c3f071fa5622f65928f73 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 30 Oct 2015 11:47:11 +0900 Subject: [PATCH] Fix a bug where DefaultPromise.toString() says 'incomplete' when it's done Motivation: DefaultPromise.toString() returns 'DefaultPromise(incomplete)' when it's actually complete with non-null result. Modifications: Handle the case where the promise is done and its result is non-null in toString() Result: The String returned by DefaultPromise.toString() is not confusing anymore. --- .../main/java/io/netty/util/concurrent/DefaultPromise.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java index 142b88d557..c4775a34e8 100644 --- a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java +++ b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java @@ -817,12 +817,17 @@ public class DefaultPromise extends AbstractFuture implements Promise { } else if (result == UNCANCELLABLE) { buf.append("(uncancellable)"); } else if (result instanceof CauseHolder) { - buf.append("(failure(") + buf.append("(failure: ") .append(((CauseHolder) result).cause) .append(')'); + } else if (result != null) { + buf.append("(success: ") + .append(result) + .append(')'); } else { buf.append("(incomplete)"); } + return buf; }