From dev-return-25429-apmail-mina-dev-archive=mina.apache.org@mina.apache.org Tue Jun 18 18:30:20 2013 Return-Path: X-Original-To: apmail-mina-dev-archive@www.apache.org Delivered-To: apmail-mina-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D6FC810DEE for ; Tue, 18 Jun 2013 18:30:20 +0000 (UTC) Received: (qmail 32851 invoked by uid 500); 18 Jun 2013 18:30:20 -0000 Delivered-To: apmail-mina-dev-archive@mina.apache.org Received: (qmail 32826 invoked by uid 500); 18 Jun 2013 18:30:20 -0000 Mailing-List: contact dev-help@mina.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mina.apache.org Delivered-To: mailing list dev@mina.apache.org Received: (qmail 32817 invoked by uid 99); 18 Jun 2013 18:30:20 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Jun 2013 18:30:20 +0000 Date: Tue, 18 Jun 2013 18:30:20 +0000 (UTC) From: "Julien Vermillard (JIRA)" To: dev@mina.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (DIRMINA-869) NioTcpServer is not thread-safe when unbinding sockets MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DIRMINA-869?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Julien Vermillard resolved DIRMINA-869. --------------------------------------- Resolution: Fixed Assignee: Julien Vermillard > NioTcpServer is not thread-safe when unbinding sockets > ------------------------------------------------------ > > Key: DIRMINA-869 > URL: https://issues.apache.org/jira/browse/DIRMINA-869 > Project: MINA > Issue Type: Bug > Components: Core > Affects Versions: 3.0.0-trunk > Reporter: Martin Ellis > Assignee: Julien Vermillard > Fix For: 3.0.0-M1 > > > The addresses field is a HashSet wrapped using Collections.synchronizedSet. > The modifications to the set in the bind(...) and unbind(...) method, are guarded by synchronizing on 'this'. > However, the unbindAll() method iterates over the set, without synchronization. This could lead to a bug if a call to unbindAll() is made while a socket is being bind()'ed or unbind()'ed. > From NioTcpServer: > private Set addresses = > Collections.synchronizedSet(new HashSet()); > ... > public void unbindAll() throws IOException { > for (SocketAddress socketAddress : addresses) { > unbind(socketAddress); > } > } > From the unsynchronizedSet javadoc. > It is imperative that the user manually synchronize on the returned set when iterating over it: > Set s = Collections.synchronizedSet(new HashSet()); > ... > synchronized(s) { > Iterator i = s.iterator(); // Must be in the synchronized block > while (i.hasNext()) > foo(i.next()); > } > Another fix might be to use a set from java.util.concurrent. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira