Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-30168

Pick random port to start webserver

    XMLWordPrintable

Details

    Description

      In the source code there is for loop to pick up the right port this leads to various outputs in the console trying to start a webserver.

      It would be a better option to add function to retrieve a random open port for this.

      Something like:

      public static int findFreePort() {
      ServerSocket socket= null;
      try

      { socket= new ServerSocket(0); return socket.getLocalPort(); }

      catch (IOException e) {
      } finally {
      if (socket != null) {
      try

      { socket.close(); }

      catch (IOException e) {
      }
      }
      }
      return -1;
      }
      (this function template is taken from org.eclipse.jdt.launching.SocketUtil)

      Best regards,
      Falk

      Attachments

        Activity

          Thank you for your pull request - I have taken your solution for release 1.5

          tbaum Dimitri Tenenbaum added a comment - Thank you for your pull request - I have taken your solution for release 1.5

          People

            tbaum Dimitri Tenenbaum
            zilmtt Falk Zilm
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: