Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

Expand All @@ -57,6 +58,7 @@
import org.springframework.cloud.stream.messaging.DirectWithAttributesChannel;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.codec.CodecException;
import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.config.GlobalChannelInterceptor;
Expand Down Expand Up @@ -203,6 +205,23 @@ void test_2249() {
}
}

// For more context on this test: https://github.com/spring-cloud/spring-cloud-stream/issues/3078
@Test
void functionInvocationWrapperNullError() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
TestChannelBinderConfiguration.getCompleteConfiguration(
EmptyConfiguration.class)).web(WebApplicationType.NONE).run(
"--spring.cloud.stream.source=outputA",
"--spring.jmx.enabled=false")) {
StreamBridge streamBridge = context.getBean(StreamBridge.class);
var exception = Assertions.assertThrows(RuntimeException.class, () -> streamBridge.send("outputA-out-0",
new CodecException("invalidException")
));

assertThat(exception.getMessage()).isEqualTo("org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper returned null");
}
}

// For more context on this test: https://github.com/spring-cloud/spring-cloud-stream/issues/2815
@Test
void ensurePartitioningWorksWhenNativeEncodingEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,13 @@ public boolean send(String bindingName, @Nullable String binderName, Object data
lock.unlock();
}

if (resultMessage == null
&& ((Message) messageToSend).getPayload().getClass().getName().equals("org.springframework.kafka.support.KafkaNull")) {
resultMessage = messageToSend;
if (resultMessage == null) {
if (((Message) messageToSend).getPayload().getClass().getName().equals("org.springframework.kafka.support.KafkaNull")) {
resultMessage = messageToSend;
}
else {
throw new RuntimeException(functionToInvoke.getClass().getName() + " returned null");
}
}

resultMessage = (Message<?>) this.functionInvocationHelper.postProcessResult(resultMessage, null);
Expand Down
Loading