diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-09 16:32:01 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-09 16:32:27 +0200 |
commit | a54446040309004efbec34381bfca68ab4a4169c (patch) | |
tree | f182224ca7299e43e8d43b89bbf64bd2ecb3cd6a /sonar-server/src | |
parent | 2c8bf137ab4812fed2565524bae58e436b3af045 (diff) | |
download | sonarqube-a54446040309004efbec34381bfca68ab4a4169c.tar.gz sonarqube-a54446040309004efbec34381bfca68ab4a4169c.zip |
SONAR-5410 - Moved NetworkUtils to sonar-search module
Diffstat (limited to 'sonar-server/src')
-rw-r--r-- | sonar-server/src/test/java/org/sonar/server/search/NetworkUtils.java | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/search/NetworkUtils.java b/sonar-server/src/test/java/org/sonar/server/search/NetworkUtils.java deleted file mode 100644 index 8a76d42d29a..00000000000 --- a/sonar-server/src/test/java/org/sonar/server/search/NetworkUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.search; - -import java.io.IOException; -import java.net.ServerSocket; - -class NetworkUtils { - - static int freePort() { - for (int index = 0; index < 5; index++) { - try { - ServerSocket socket = new ServerSocket(0); - int unusedPort = socket.getLocalPort(); - socket.close(); - if (isValidPort(unusedPort)) { - return unusedPort; - } - - } catch (IOException e) { - throw new IllegalStateException("Can not find an open network port", e); - } - } - throw new IllegalStateException("Can not find an open network port"); - } - - - private static boolean isValidPort(int port) { - return port > 1023; - } -} |