From 857ad73676c23da2eb6a892a799f0f26358d60ea Mon Sep 17 00:00:00 2001 From: Scott Mitchell Date: Sat, 25 Jun 2016 13:49:17 -0700 Subject: [PATCH] DefaultPromise make MAX_STACK_DEPTH configurable Motivation: Some Netty use cases may want to configure the max allowed stack depth for promise listener notification. Modifications: - Add a system property so that this value can be configured. Result: DefaultPromise's max stack depth is configurable. --- .../main/java/io/netty/util/concurrent/DefaultPromise.java | 4 +++- 1 file changed, 3 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 16cdc0c96c..453c44adcb 100644 --- a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java +++ b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java @@ -19,6 +19,7 @@ import io.netty.util.Signal; import io.netty.util.internal.InternalThreadLocalMap; import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.StringUtil; +import io.netty.util.internal.SystemPropertyUtil; import io.netty.util.internal.ThrowableUtil; import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLoggerFactory; @@ -34,7 +35,8 @@ public class DefaultPromise extends AbstractFuture implements Promise { private static final InternalLogger logger = InternalLoggerFactory.getInstance(DefaultPromise.class); private static final InternalLogger rejectedExecutionLogger = InternalLoggerFactory.getInstance(DefaultPromise.class.getName() + ".rejectedExecution"); - private static final int MAX_LISTENER_STACK_DEPTH = 8; + private static final int MAX_LISTENER_STACK_DEPTH = Math.min(8, + SystemPropertyUtil.getInt("io.netty.defaultPromise.maxListenerStackDepth", 8)); @SuppressWarnings("rawtypes") private static final AtomicReferenceFieldUpdater RESULT_UPDATER; private static final Signal SUCCESS = Signal.valueOf(DefaultPromise.class, "SUCCESS");