You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2020/11/12 14:28:54 UTC
[geode] branch develop updated: GEODE-8664: Nest errors in
DistributionImpl.start (#5725)
This is an automated email from the ASF dual-hosted git repository.
jensdeppe pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new f6605e0 GEODE-8664: Nest errors in DistributionImpl.start (#5725)
f6605e0 is described below
commit f6605e0820ba9b858b8128cd31a03a29067b7710
Author: Mario Salazar de Torres <ma...@est.tech>
AuthorDate: Thu Nov 12 15:27:58 2020 +0100
GEODE-8664: Nest errors in DistributionImpl.start (#5725)
- If while calling DistributionImpl.start there was either a
MembershipConfigurationException or MemberStartupException exceptions, its
original cause was not propagated, therefore being unable to properly
tackle issues on startup.
- This commit propagates both exceptions.
- Also 2 junit test were added to make sure this is working.
---
.../distributed/internal/DistributionImpl.java | 4 ++--
.../distributed/internal/DistributionTest.java | 26 +++++++++++++++++++++-
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java
index c6713a3..bc0ace3 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java
@@ -181,9 +181,9 @@ public class DistributionImpl implements Distribution {
throw new GemFireSecurityException(e.getMessage(),
e);
} catch (MembershipConfigurationException e) {
- throw new GemFireConfigException(e.getMessage());
+ throw new GemFireConfigException("Problem configuring membership services", e);
} catch (MemberStartupException e) {
- throw new SystemConnectException(e.getMessage());
+ throw new SystemConnectException("Problem starting up membership services", e);
} catch (RuntimeException e) {
logger.error("Unexpected problem starting up membership services", e);
throw new SystemConnectException("Problem starting up membership services: " + e.getMessage()
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionTest.java
index 35abb5c..029a5b9 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionTest.java
@@ -15,6 +15,7 @@
package org.apache.geode.distributed.internal;
import static org.apache.geode.distributed.internal.DistributionImpl.EMPTY_MEMBER_ARRAY;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -41,11 +42,15 @@ import org.jgroups.util.UUID;
import org.junit.Before;
import org.junit.Test;
+import org.apache.geode.GemFireConfigException;
+import org.apache.geode.SystemConnectException;
import org.apache.geode.distributed.DistributedSystemDisconnectedException;
import org.apache.geode.distributed.internal.direct.DirectChannel;
import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
+import org.apache.geode.distributed.internal.membership.api.MemberStartupException;
import org.apache.geode.distributed.internal.membership.api.Membership;
import org.apache.geode.distributed.internal.membership.api.MembershipClosedException;
+import org.apache.geode.distributed.internal.membership.api.MembershipConfigurationException;
import org.apache.geode.distributed.internal.membership.gms.GMSMembership;
import org.apache.geode.internal.admin.remote.AlertListenerMessage;
import org.apache.geode.internal.admin.remote.RemoteTransportConfig;
@@ -81,7 +86,6 @@ public class DistributionTest {
distribution = new DistributionImpl(clusterDistributionManager,
remoteTransportConfig, internalDistributedSystem, membership);
-
Random r = new Random();
mockMembers = new InternalDistributedMember[5];
for (int i = 0; i < mockMembers.length; i++) {
@@ -204,4 +208,24 @@ public class DistributionTest {
distribution.send(emptyList, m);
verify(membership, never()).send(any(), any());
}
+
+ @Test
+ public void testExceptionNestedOnStartConfigError() throws Exception {
+ Throwable exception = new MembershipConfigurationException("Test exception");
+ doThrow(exception).when(membership).start();
+
+ assertThatThrownBy(() -> distribution.start())
+ .isInstanceOf(GemFireConfigException.class)
+ .hasCause(exception);
+ }
+
+ @Test
+ public void testExceptionNestedOnStartStartupError() throws Exception {
+ Throwable exception = new MemberStartupException("Test exception");
+ doThrow(exception).when(membership).start();
+
+ assertThatThrownBy(() -> distribution.start())
+ .isInstanceOf(SystemConnectException.class)
+ .hasCause(exception);
+ }
}