Go to file
Trustin Lee dbbc6ad73f Reduce the chance of RejectedExecutionException
When a Netty application shuts down, a user often sees a REE
(RejectedExecutionException).

A REE is raised due to various reasons we don't have control over, such
as:

- A client connects to a server while the server is shutting down.

- An event is triggered for a closed Channel while its event loop is
  also shutting down.  Some of them are:
  - channelDeregistered (triggered after a channel is closed)
  - freeIn/OutboundBuffer (triggered after channelDeregistered)
  - userEventTriggered (triggered anytime)

To address this issue, a new method called confirmShutdown() has been
added to SingleThreadEventExecutor.  After a user calls shutdown(),
confirmShutdown() runs any remaining tasks in the task queue and ensures
no events are triggered for last 2 seconds.  If any task are added to
the task queue before 2 seconds passes, confirmShutdown() prevents the
event loop from terminating by returning false.

Now that SingleThreadEventExecutor needs to accept tasks even after
shutdown(), its execute() method only rejects the task after the event
loop is terminated (i.e. isTerminated() returns true.)  Except that,
there's no change in semantics.

SingleThreadEventExecutor also checks if its subclass called
confirmShutdown() in its run() implementation, so that Netty developers
can make sure they shut down their event loop impementation correctly.

It also fixes a bug in AioSocketChannel, revealed by delayed shutdown,
where an inboundBufferUpdated() event is triggered on a closed Channel
with deallocated buffers.

Caveats:

Because SingleThreadEventExecutor.takeTask() does not have a notion of
timeout, confirmShutdown() adds a dummy task (WAKEUP_TASK) to wake up
takeTask() immediately and instead sleeps hard-coded 100ms.  I'll
address this issue later by modifying takeTask() times out dynamically.

Miscellaneous changes:

SingleThreadEventExecutor.wakeup() now has the default implementation.
Instead of interrupting the current thread, it simply adds a dummy task
(WAKEUP_TASK) to the task queue, which is more elegant and efficient.
NioEventLoop is the only implementation that overrides it. All other
implementations' wakeup()s were removed thanks to this change.
2012-11-22 20:36:13 +01:00
all Only generate OSGi manifest only at all-in-on sub module to reduce the complexity to the build 2012-11-19 06:27:18 +01:00
buffer ByteBufAllocator API w/ ByteBuf perf improvements 2012-11-22 15:10:59 +09:00
codec ByteBufAllocator API w/ ByteBuf perf improvements 2012-11-22 15:10:59 +09:00
codec-http ByteBufAllocator API w/ ByteBuf perf improvements 2012-11-22 15:10:59 +09:00
codec-socks basic support for socks5 codec 2012-11-17 20:03:16 +01:00
common ByteBufAllocator API w/ ByteBuf perf improvements 2012-11-22 15:10:59 +09:00
example basic support for socks5 codec 2012-11-17 20:03:16 +01:00
handler ByteBufAllocator API w/ ByteBuf perf improvements 2012-11-22 15:10:59 +09:00
license Added webbit license and credits 2011-10-27 10:34:37 +11:00
metrics-yammer Only generate OSGi manifest only at all-in-on sub module to reduce the complexity to the build 2012-11-19 06:27:18 +01:00
tarball [maven-release-plugin] prepare for next development iteration 2012-11-05 23:08:39 +01:00
testsuite Fix inspection warnings related with JUnit usage 2012-11-12 12:45:06 +09:00
transport Reduce the chance of RejectedExecutionException 2012-11-22 20:36:13 +01:00
.fbfilter.xml Update license headers 2012-06-04 13:31:44 -07:00
.fbprefs Updated Find Bugs configuration 2009-03-04 10:33:09 +00:00
.gitignore ignore .idea/ folder 2012-01-16 16:01:00 +08:00
LICENSE.txt Relicensed to Apache License v2 2009-08-28 07:15:49 +00:00
NOTICE.txt More copyright updates 2011-12-09 14:28:48 +09:00
pom.xml Only generate OSGi manifest only at all-in-on sub module to reduce the complexity to the build 2012-11-19 06:27:18 +01:00
README.md Fix README 2012-09-08 20:20:45 +02:00

The Netty Project

Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients.

Getting Netty

    <dependencies>
      ...
      <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty</artifactId>
        <version>X.Y.Z.Q</version>
        <scope>compile</scope>
      </dependency>
      ...
    </dependencies>

Developer Information

  • Netty is setup to build using Maven

  • You need JDK 7 to build Netty. Netty will run with JDK 5 (3.x) and JDK 6 (4).

  • master branch contains code for Netty 4.x

  • 3 branch contains code for Netty 3.x