| Summary: | [JUnit] JUnit launch target fails to start because port is released and reacquired | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Michael Schneider <michschn> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | daniel_megert, markus.kell.r |
| Version: | 3.6 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | stalebug | ||
|
Description
Michael Schneider
org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate#evaluatePort() finds a free port and stores it as a launch attribute. Later, JUnitLaunchListener#launchChanged(ILaunch) reads the port and in the end, RemoteTestRunnerClient.ServerConnection#run() opens the ServerSocket again. In between, there's an opportunity for others to take the same port. We should open the socket only once and pass it on to the ServerConnection. The fix is not as trivial as it sounds. We cannot directly pass the ServerSocket, since Debug implements the launching and we don't have a channel to pass arbitrary objects from JUnitLaunchConfigurationDelegate to the RemoteTestRunnerClient.ServerConnection (or to the ILaunch). We need to go via a static cache in JUnitModel, and we have to make sure that ServerSockets are closed eventually, even if launching failed (so a WeakHashMap is not enough). Furthermore, when I tested SocketUtil.findFreePort() on Windows 7, I got an increased value on each call, even if the port was not used in between. So clashing ports shouldn't be an issue with well-behaved other parties that also use "new ServerSocket(0)" instead of a home-brewed port number finder. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |