https://issues.apache.org/bugzilla/show_bug.cgi?id=49686
Summary: Using an instance lock to protect static shared data in class SocketConnector Product: Tomcat 7 Version: 7.0.0 Platform: PC OS/Version: Windows XP Status: NEW Severity: normal Priority: P2 Component: Modules: tomcat-lite AssignedTo: dev@tomcat.apache.org ReportedBy: feng_yu_...@hotmail.com SocketConnector has the unsafe synchronization as follow. public class SocketConnector extends IOConnector { ... static int id = 0; public synchronized NioThread getSelector() { if (selector == null) { String name = "SelectorThread-" + id++; selector = new NioThread(name, true); } return selector; } ... } id is a static shared data, and it is not proper to use a instance lock to protect it, especially when two instance of the class are created. it would be more safer to write this instead: public static synchronized NioThread getSelector() { if (selector == null) { String name = "SelectorThread-" + id++; selector = new NioThread(name, true); } return selector; } -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org