From e0bef12e2cb2aa8df9f43e37da26e6b6eb5702a2 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 1 Sep 2009 08:41:36 +0000 Subject: [PATCH] Fixed a bug where AsynchronousCloseException causes IndexOutOfBoundsException during write --- .../org/jboss/netty/channel/socket/nio/NioDatagramWorker.java | 2 ++ .../java/org/jboss/netty/channel/socket/nio/NioWorker.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java index 8494e7073b..f5de0e1ddd 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioDatagramWorker.java @@ -539,7 +539,9 @@ class NioDatagramWorker implements Runnable { } } catch (final AsynchronousCloseException e) { // Doesn't need a user attention - ignore. + channel.currentWriteEvent = evt; } catch (final Throwable t) { + channel.currentWriteEvent = null; evt.getFuture().setFailure(t); evt = null; fireExceptionCaught(channel, t); diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java index 94466628ea..13528fa3a3 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java @@ -454,13 +454,17 @@ class NioWorker implements Runnable { } } catch (AsynchronousCloseException e) { // Doesn't need a user attention - ignore. + channel.currentWriteEvent = evt; + channel.currentWriteIndex = bufIdx; } catch (Throwable t) { + channel.currentWriteEvent = null; evt.getFuture().setFailure(t); evt = null; fireExceptionCaught(channel, t); if (t instanceof IOException) { open = false; close(channel, succeededFuture(channel)); + break; } } }