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

lhotari pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new de8f543fb9b [fix][test] Fix resource leak in PulsarServiceTest (#21386)
de8f543fb9b is described below

commit de8f543fb9be71208578f35fcb397e7db3482107
Author: Lari Hotari <[email protected]>
AuthorDate: Wed Oct 18 03:05:52 2023 +0300

    [fix][test] Fix resource leak in PulsarServiceTest (#21386)
---
 .../java/org/apache/pulsar/broker/PulsarServiceTest.java   | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceTest.java 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceTest.java
index 3e0887646e1..daa4393db55 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceTest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/PulsarServiceTest.java
@@ -188,7 +188,7 @@ public class PulsarServiceTest extends 
MockedPulsarServiceBaseTest {
     }
 
     @Test
-    public void testBacklogAndRetentionCheck() {
+    public void testBacklogAndRetentionCheck() throws PulsarServerException {
         ServiceConfiguration config = new ServiceConfiguration();
         config.setClusterName("test");
         config.setMetadataStoreUrl("memory:local");
@@ -200,6 +200,8 @@ public class PulsarServiceTest extends 
MockedPulsarServiceBaseTest {
             pulsarService.start();
         } catch (Exception e) {
             assertFalse(e.getCause() instanceof IllegalArgumentException);
+        } finally {
+            pulsarService.close();
         }
 
         // Only set retention
@@ -212,6 +214,8 @@ public class PulsarServiceTest extends 
MockedPulsarServiceBaseTest {
             pulsarService.start();
         } catch (Exception e) {
             assertFalse(e.getCause() instanceof IllegalArgumentException);
+        } finally {
+            pulsarService.close();
         }
 
         // Set both retention and backlog quota
@@ -224,6 +228,8 @@ public class PulsarServiceTest extends 
MockedPulsarServiceBaseTest {
             pulsarService.start();
         } catch (Exception e) {
             assertFalse(e.getCause() instanceof IllegalArgumentException);
+        } finally {
+            pulsarService.close();
         }
 
         // Set invalidated retention and backlog quota
@@ -235,6 +241,8 @@ public class PulsarServiceTest extends 
MockedPulsarServiceBaseTest {
             pulsarService.start();
         } catch (Exception e) {
             assertTrue(e.getCause() instanceof IllegalArgumentException);
+        } finally {
+            pulsarService.close();
         }
 
         config.setBacklogQuotaDefaultLimitBytes(4 * 1024 * 1024);
@@ -246,6 +254,8 @@ public class PulsarServiceTest extends 
MockedPulsarServiceBaseTest {
             pulsarService.start();
         } catch (Exception e) {
             assertTrue(e.getCause() instanceof IllegalArgumentException);
+        } finally {
+            pulsarService.close();
         }
 
         // Only set backlog quota
@@ -258,6 +268,8 @@ public class PulsarServiceTest extends 
MockedPulsarServiceBaseTest {
             pulsarService.start();
         } catch (Exception e) {
             assertFalse(e.getCause() instanceof IllegalArgumentException);
+        } finally {
+            pulsarService.close();
         }
     }
 }

Reply via email to