Repository: kafka
Updated Branches:
  refs/heads/trunk 8248caf1c -> 286411cbb


KAFKA-4129; Processor throw exception when getting channel remote address after 
closing the channel

Get channel remote address before calling ```channel.close```

Author: Tao Xiao <[email protected]>

Reviewers: Ismael Juma <[email protected]>

Closes #1826 from xiaotao183/KAFKA-4129


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/286411cb
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/286411cb
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/286411cb

Branch: refs/heads/trunk
Commit: 286411cbb19ad267516c73e0a5a8a22e8341b9ad
Parents: 8248caf
Author: Tao Xiao <[email protected]>
Authored: Wed Sep 7 01:17:29 2016 +0100
Committer: Ismael Juma <[email protected]>
Committed: Wed Sep 7 01:17:29 2016 +0100

----------------------------------------------------------------------
 core/src/main/scala/kafka/network/SocketServer.scala | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/286411cb/core/src/main/scala/kafka/network/SocketServer.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/network/SocketServer.scala 
b/core/src/main/scala/kafka/network/SocketServer.scala
index fcf0bc5..90a0fee 100644
--- a/core/src/main/scala/kafka/network/SocketServer.scala
+++ b/core/src/main/scala/kafka/network/SocketServer.scala
@@ -548,9 +548,10 @@ private[kafka] class Processor(val id: Int,
         // We explicitly catch all non fatal exceptions and close the socket 
to avoid a socket leak. The other
         // throwables will be caught in processor and logged as uncaught 
exceptions.
         case NonFatal(e) =>
+          val remoteAddress = channel.getRemoteAddress
           // need to close the channel here to avoid a socket leak.
           close(channel)
-          error(s"Processor $id closed connection from 
${channel.getRemoteAddress}", e)
+          error(s"Processor $id closed connection from $remoteAddress", e)
       }
     }
   }

Reply via email to