Skip to content

Commit 79f642c

Browse files
committed
GEODE-10490: Clean up partial DS on retry and fix null pointer in test cleanup
1. LocatorStarterRule: Added cleanup of partial distributed system before retry. When startLocatorAndDS() fails with port binding error, it may have partially created a DS. This causes 'distributed system already exists' error on retry. Now properly stop locator and disconnect DS before retrying. 2. HeadlessGfshIntegrationTest: Added null checks in cleanup() method. If setup() fails (e.g., port binding failure), gfsh/cache/ds may be null, causing NullPointerException in @after cleanup. Added defensive null checks.
1 parent 6e7573f commit 79f642c

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

geode-dunit/src/main/java/org/apache/geode/test/junit/rules/LocatorStarterRule.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ public void startLocator() {
113113

114114
} catch (IOException e) {
115115
lastException = e;
116+
117+
// Clean up any partial distributed system that may have been created
118+
try {
119+
if (locator != null) {
120+
locator.stop();
121+
locator = null;
122+
}
123+
disconnectDSIfAny();
124+
} catch (Exception cleanupException) {
125+
// Ignore cleanup errors
126+
}
127+
116128
// Check if this is a port binding failure
117129
if (e.getMessage() != null && e.getMessage().contains("Address already in use")
118130
&& attempt < maxRetries) {

geode-gfsh/src/integrationTest/java/org/apache/geode/management/internal/cli/HeadlessGfshIntegrationTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ private void legacyConnect(Properties properties) {
9191
@SuppressWarnings({"deprecation"})
9292
@After
9393
public void cleanup() {
94-
gfsh.terminate();
95-
cache.close();
96-
ds.disconnect();
94+
if (gfsh != null) {
95+
gfsh.terminate();
96+
}
97+
if (cache != null) {
98+
cache.close();
99+
}
100+
if (ds != null) {
101+
ds.disconnect();
102+
}
97103
}
98104

99105
@Test

0 commit comments

Comments
 (0)