From 6f18c940dd255419893a99cdc26f2df09201f533 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 30 Sep 2008 00:31:32 +0000 Subject: [PATCH] Fixed issue NETTY-50 (Dead lock in MemoryAwareThreadPoolExecutor) * Made sure that the max memory size properties become immutable --- .../execution/MemoryAwareThreadPoolExecutor.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java b/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java index 2345ee22da..10d949b595 100644 --- a/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java +++ b/src/main/java/org/jboss/netty/handler/execution/MemoryAwareThreadPoolExecutor.java @@ -197,6 +197,12 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor { throw new IllegalArgumentException( "maxChannelMemorySize: " + maxChannelMemorySize); } + + if (getTaskCount() > 0) { + throw new IllegalStateException( + "can't be changed after a task is executed"); + } + settings = new Settings(maxChannelMemorySize, settings.maxTotalMemorySize); } @@ -216,6 +222,12 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor { throw new IllegalArgumentException( "maxTotalMemorySize: " + maxTotalMemorySize); } + + if (getTaskCount() > 0) { + throw new IllegalStateException( + "can't be changed after a task is executed"); + } + settings = new Settings(settings.maxChannelMemorySize, maxTotalMemorySize); }