Skip to content

Apache Lucene open-source search software

SOLR-13864: SolrTestCaseJ4.getNextAvailablePort() has been deprecated

Chris Hostetter603be023feaf
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 5cc85e9c907..4d855b9f539 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -164,6 +164,9 @@ Other Changes
* SOLR-13824: Strictly reject anything after JSON in most APIs (Mikhail Khludnev, Munendra S N)
+* SOLR-13864: SolrTestCaseJ4.getNextAvailablePort() has been deprecated (and will be removed in 9.0) since
+ it is fundementally flawed. Users with tests that depend on this method should restructure them. (hossman)
+
================== 8.3.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index 8b5a8f97164..b9130745804 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -902,7 +902,10 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
* Find next available local port.
* @return available port number or -1 if none could be found
* @throws Exception on IO errors
+ * @see <a href="https://issues.apache.org/jira/browse/SOLR-13869">SOLR-13869</a>
+ * @deprecated This method is inherently flawed, see SOLR-13869
*/
+ @Deprecated
protected static int getNextAvailablePort() throws Exception {
int port = -1;
try (ServerSocket s = new ServerSocket(0)) {