Repository: smallrye/smallrye-reactive-messaging
Issue: Exception thrown from connector during startup discarded by provider with cause thrown instead

If an exception occurs when a connector creates its subscriber or producer, if that exception has a cause, the exception itself is discarded and the cause is reported as a deployment error.

This happens here: https://github.com/smallrye/smallrye-reactive-messaging/blob/master/smallrye-reactive-messaging-provider/src/main/java/io/smallrye/reactive/messaging/extension/ReactiveMessagingExtension.java#L135

This was unhelpful in my connector, because the exception that was discarded contained the information about which channel the connector failed for.

Changed files:
smallrye-reactive-messaging-provider/src/test/java/io/smallrye/reactive/messaging/merge/InvalidBindingTest.java
smallrye-reactive-messaging-provider/src/main/java/io/smallrye/reactive/messaging/extension/ReactiveMessagingExtension.java

diff --git a/smallrye-reactive-messaging-provider/src/main/java/io/smallrye/reactive/messaging/extension/ReactiveMessagingExtension.java b/smallrye-reactive-messaging-provider/src/main/java/io/smallrye/reactive/messaging/extension/ReactiveMessagingExtension.java
index fdc018899..233fb0ed6 100644
--- a/smallrye-reactive-messaging-provider/src/main/java/io/smallrye/reactive/messaging/extension/ReactiveMessagingExtension.java
+++ b/smallrye-reactive-messaging-provider/src/main/java/io/smallrye/reactive/messaging/extension/ReactiveMessagingExtension.java
@@ -132,12 +132,7 @@ public class ReactiveMessagingExtension implements Extension {
             }
 
         } catch (Exception e) {
-            if (e.getCause() == null) {
-                done.addDeploymentProblem(e);
-            } else {
-                done.addDeploymentProblem(e.getCause());
-            }
-
+            done.addDeploymentProblem(e);
         }
     }
 
diff --git a/smallrye-reactive-messaging-provider/src/test/java/io/smallrye/reactive/messaging/merge/InvalidBindingTest.java b/smallrye-reactive-messaging-provider/src/test/java/io/smallrye/reactive/messaging/merge/InvalidBindingTest.java
index 4da66dedc..669e6c31a 100644
--- a/smallrye-reactive-messaging-provider/src/test/java/io/smallrye/reactive/messaging/merge/InvalidBindingTest.java
+++ b/smallrye-reactive-messaging-provider/src/test/java/io/smallrye/reactive/messaging/merge/InvalidBindingTest.java
@@ -39,7 +39,7 @@ public class InvalidBindingTest extends WeldTestBaseWithoutTails {
             fail("Invalid weaving not detected");
         } catch (DeploymentException e) {
             assertThat(e.getCause())
-                    .isInstanceOf(WeavingException.class)
+                    .hasCauseInstanceOf(WeavingException.class)
                     .hasMessageContaining("`source`")
                     .hasMessageContaining("#sink")
                     .hasMessageContaining("(2)");
@@ -70,7 +70,8 @@ public class InvalidBindingTest extends WeldTestBaseWithoutTails {
         } catch (DeploymentException e) {
             e.getCause().printStackTrace();
             assertThat(e.getCause())
-                    .isInstanceOf(WeavingException.class)
+                    .isInstanceOf(DeploymentException.class)
+                    .hasCauseInstanceOf(WeavingException.class)
                     .hasMessageContaining("source")
                     .hasMessageContaining("Synchronous");
         }