From cebcbed7d98f3965f0283b04663e11411cec53b4 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:45:45 +0000 Subject: [PATCH] feat: log stacktrace (#3418) * feat: log stacktrace * use string writer * reformat * modify test * log exception along the message --- .../integration/inbound/PubSubInboundChannelAdapter.java | 4 ++-- .../inbound/PubSubInboundChannelAdapterTests.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/integration/inbound/PubSubInboundChannelAdapter.java b/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/integration/inbound/PubSubInboundChannelAdapter.java index 14ad6ad288..21bb4990fb 100644 --- a/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/integration/inbound/PubSubInboundChannelAdapter.java +++ b/spring-cloud-gcp-pubsub/src/main/java/com/google/cloud/spring/pubsub/integration/inbound/PubSubInboundChannelAdapter.java @@ -175,9 +175,9 @@ private void logWarning( // so we explicitly log failure messages. // See https://github.com/spring-projects/spring-framework/issues/25162 for more info. if (re instanceof MessageDeliveryException messageDeliveryException) { - LOGGER.warn(messageDeliveryException.getFailedMessage()); + LOGGER.warn(messageDeliveryException.getFailedMessage(), messageDeliveryException); } else { - LOGGER.warn(re.getMessage()); + LOGGER.warn(re.getMessage(), re); } } diff --git a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/integration/inbound/PubSubInboundChannelAdapterTests.java b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/integration/inbound/PubSubInboundChannelAdapterTests.java index 05289026e6..925fc53ded 100644 --- a/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/integration/inbound/PubSubInboundChannelAdapterTests.java +++ b/spring-cloud-gcp-pubsub/src/test/java/com/google/cloud/spring/pubsub/integration/inbound/PubSubInboundChannelAdapterTests.java @@ -166,7 +166,10 @@ void testAckModeAuto_nacksWhenDownstreamProcessingFailsWhenContextShutdown(Captu verify(mockAcknowledgeableMessage, times(0)).ack(); // original message handling exception - assertThat(capturedOutput).contains("failed; message nacked automatically").contains(EXCEPTION_MESSAGE); + assertThat(capturedOutput) + .contains("failed; message nacked automatically") + .contains(EXCEPTION_MESSAGE) + .contains("Caused by"); } @Test