This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new f955c305a35 LB2SolrClientTest: improve teardown (#4221)
f955c305a35 is described below
commit f955c305a357ce38b89fcb8cafa7d3d15a0ee6fd
Author: David Smiley <[email protected]>
AuthorDate: Tue Mar 17 20:18:50 2026 -0400
LB2SolrClientTest: improve teardown (#4221)
---
.../solr/client/solrj/impl/LB2SolrClientTest.java | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git
a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LB2SolrClientTest.java
b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LB2SolrClientTest.java
index 66e806e9538..849d8953c0f 100644
---
a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LB2SolrClientTest.java
+++
b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LB2SolrClientTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.solr.client.solrj.impl;
+import java.io.Closeable;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.ServerSocket;
@@ -100,11 +101,7 @@ public class LB2SolrClientTest extends SolrTestCaseJ4 {
@Override
public void tearDown() throws Exception {
- for (SolrInstance aSolr : solr) {
- if (aSolr != null) {
- aSolr.tearDown();
- }
- }
+ IOUtils.close(solr); // closes all solr instances in 'solr[]', and throws
if failed
super.tearDown();
}
@@ -286,7 +283,7 @@ public class LB2SolrClientTest extends SolrTestCaseJ4 {
}
}
- private static class SolrInstance {
+ private static class SolrInstance implements Closeable {
String name;
Path homeDir;
Path dataDir;
@@ -339,9 +336,16 @@ public class LB2SolrClientTest extends SolrTestCaseJ4 {
Files.createFile(homeDir.resolve("collection1/core.properties"));
}
- public void tearDown() throws Exception {
- if (jetty != null) jetty.stop();
- IOUtils.rm(homeDir);
+ @Override
+ public void close() throws IOException {
+ try {
+ if (jetty != null) jetty.stop();
+ IOUtils.rm(homeDir);
+ } catch (IOException | RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
public void startJetty() throws Exception {