private static RemoteConnection doPatch(@NotNull JavaParameters javaParameters,
                                          @NotNull RunnerSettings settings,
                                          boolean beforeExecution,
                                          @Nullable Project project)
    throws ExecutionException {
    GenericDebuggerRunnerSettings debuggerSettings = ((GenericDebuggerRunnerSettings)settings);
    if (StringUtil.isEmpty(debuggerSettings.getDebugPort())) {
      debuggerSettings.setDebugPort(
        DebuggerUtils.getInstance().findAvailableDebugAddress(debuggerSettings.getTransport() == DebuggerSettings.SOCKET_TRANSPORT));
    }
    return new RemoteConnectionBuilder(debuggerSettings.LOCAL, debuggerSettings.getTransport(), debuggerSettings.getDebugPort())
      .asyncAgent(beforeExecution)
      .project(project)
      .create(javaParameters);
  }
private static RemoteConnection doPatch(@NotNull JavaParameters javaParameters,
                                          @NotNull RunnerSettings settings,
                                          boolean beforeExecution,
                                          @Nullable Project project)