You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2020/05/15 21:50:56 UTC

[lucene-solr] branch branch_8x updated: LUCENE-9232: Fix or suppress 13 resource leak precommit warnings in lucene/replicator

This is an automated email from the ASF dual-hosted git repository.

erick pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new b7b6e4a  LUCENE-9232: Fix or suppress 13 resource leak precommit warnings in lucene/replicator
b7b6e4a is described below

commit b7b6e4a072f3fe665dc37b0d9c6f993d1be10d11
Author: erick <er...@gmail.com>
AuthorDate: Fri May 15 17:44:15 2020 -0400

    LUCENE-9232: Fix or suppress 13 resource leak precommit warnings in lucene/replicator
---
 lucene/CHANGES.txt                                      |  2 ++
 .../apache/lucene/replicator/ReplicatorTestCase.java    |  2 ++
 .../lucene/replicator/nrt/TestNRTReplication.java       | 17 +++++++++++------
 .../lucene/replicator/nrt/TestStressNRTReplication.java |  6 ++++--
 4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 5460ae2..45cbe40 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -148,6 +148,8 @@ Other
 
 * LUCENE-9288: poll_mirrors.py release script can handle HTTPS mirrors. (Ignacio Vera)
 
+* LUCENE-9232: Fix or suppress 13 resource leak precommit warnings in lucene/replicator (Andras Salamon via Erick Erickson)
+
 Build
 
 * Upgrade forbiddenapis to version 3.0.  (Uwe Schindler)
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java b/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java
index c2f47bf..e2cd311 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/ReplicatorTestCase.java
@@ -99,10 +99,12 @@ public abstract class ReplicatorTestCase extends LuceneTestCase {
       HttpConfiguration configuration = new HttpConfiguration();
       configuration.setSecureScheme("https");
       configuration.addCustomizer(new SecureRequestCustomizer());
+      @SuppressWarnings("resource")
       ServerConnector c = new ServerConnector(server, new SslConnectionFactory(sslcontext, "http/1.1"),
           new HttpConnectionFactory(configuration));
       connector = c;
     } else {
+      @SuppressWarnings("resource")
       ServerConnector c = new ServerConnector(server, new HttpConnectionFactory());
       connector = c;
     }
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java
index 05f02cc..b41e0f9 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestNRTReplication.java
@@ -271,7 +271,7 @@ public class TestNRTReplication extends LuceneTestCase {
     waitForVersionAndHits(replica, primaryVersion3, 10);
 
     primaryC.close();
-
+    docs.close();
     replica.close();
     primary.close();
   }
@@ -320,7 +320,7 @@ public class TestNRTReplication extends LuceneTestCase {
     waitForVersionAndHits(replica, primaryVersion3, 20);
 
     primaryC.close();
-
+    docs.close();
     replica.close();
     primary.close();
   }
@@ -366,7 +366,7 @@ public class TestNRTReplication extends LuceneTestCase {
     // Ask replica to sync:
     replica.newNRTPoint(primaryVersion1, 0, primary.tcpPort);
     waitForVersionAndHits(replica, primaryVersion1, 10);
-
+    docs.close();
     replica.close();
     primary.close();
   }
@@ -409,7 +409,7 @@ public class TestNRTReplication extends LuceneTestCase {
 
     // On startup the replica searches the last commit:
     assertVersionAndHits(replica, primaryVersion1, 10);
-
+    docs.close();
     replica.close();
     primary.close();
   }
@@ -474,7 +474,7 @@ public class TestNRTReplication extends LuceneTestCase {
     replica.newNRTPoint(primaryVersion2, 0, primary.tcpPort);
 
     waitForVersionAndHits(replica, primaryVersion2, 20);
-
+    docs.close();
     replica.close();
     primary.close();
   }
@@ -508,6 +508,8 @@ public class TestNRTReplication extends LuceneTestCase {
     // Wait for replica to sync up:
     waitForVersionAndHits(replica, primaryVersion1, 10);
 
+    docs.close();
+
     // Crash primary:
     primary.crash();
 
@@ -586,6 +588,7 @@ public class TestNRTReplication extends LuceneTestCase {
     // Wait for replica to sync up:
     waitForVersionAndHits(replica, primaryVersion2, 20);
 
+    docs.close();
     primary.close();
     replica.close();
   }
@@ -693,7 +696,7 @@ public class TestNRTReplication extends LuceneTestCase {
         assertEquals(100, hitCount);
       }
     }
-
+    docs.close();
     primary.close();
     replica.close();
   }
@@ -763,6 +766,7 @@ public class TestNRTReplication extends LuceneTestCase {
     // Make sure it sees all docs that were indexed while it was down:
     assertVersionAndHits(primary, primaryVersion2, 110);
 
+    docs.close();
     replica.close();
     primary.close();
   }
@@ -832,6 +836,7 @@ public class TestNRTReplication extends LuceneTestCase {
     assertVersionAndHits(replica1, primary.initInfosVersion, 50);
     assertVersionAndHits(replica2, primary.initInfosVersion, 50);
 
+    docs.close();
     primary.close();
     replica1.close();
     replica2.close();
diff --git a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java
index d11b22b..d431dc1 100644
--- a/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java
+++ b/lucene/replicator/src/test/org/apache/lucene/replicator/nrt/TestStressNRTReplication.java
@@ -1057,9 +1057,9 @@ public class TestStressNRTReplication extends LuceneTestCase {
 
     @Override
     public void run() {
-
+      LineFileDocs docs=null;
       try {
-        LineFileDocs docs = new LineFileDocs(random());
+        docs = new LineFileDocs(random());
         int docCount = 0;
 
         // How often we do an update/delete vs add:
@@ -1175,6 +1175,8 @@ public class TestStressNRTReplication extends LuceneTestCase {
         failed.set(true);
         stop.set(true);
         throw new RuntimeException(t);
+      } finally {
+        IOUtils.closeWhileHandlingException(docs);
       }
     }
   }