StreamBridge null pointer with Spring 3

I try to get “spring-cloud-starter-stream-solace” version 3.0.0 with spring 3.1.0 running.
But every time i use the “StreamBridge” i get this error message:
2023-06-01T14:38:25.602+0200 ERROR Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed: java.lang.NullPointerException: Cannot load from object array because “contentType” is null] with root cause
java.lang.NullPointerException: Cannot load from object array because “contentType” is null
at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.convertOutputIfNecessary(SimpleFunctionRegistry.java:1170) ~[spring-cloud-function-context-4.0.2.jar:4.0.2]
at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvocationWrapper.doApply(SimpleFunctionRegistry.java:708) ~[spring-cloud-function-context-4.0.2.jar:4.0.2]
at org.springframework.cloud.function.context.catalog.SimpleFunctionRegistry$FunctionInvo
Didt some one else tried to use spring 3 and get it run?
The sample code:
@GetMapping(value = “/temperature/publish/dynamic_topic/{location}/{temperature}”)
public void publishTemperatureDynamicTopic(
@PathVariable(“location”) final String location,
@PathVariable(“temperature”) final double temperature
) {
SensorReading reading = new SensorReading();
reading.setSensorID(location);
reading.setTemperature(temperature);
reading.setBaseUnit(BaseUnit.CELSIUS);
log.info("Emitting " + reading);
Message message = MessageBuilder
.withPayload(reading)
.setHeader(
BinderHeaders.TARGET_DESTINATION,
baseDestination + “/” + location)
.build();
streamBridge.send(“emitTemperatureSensorDynamic-out-0”, message);
}
My pom.xml

<?xml version="1.0" encoding="UTF-8"?>


    4.0.0
   
        org.springframework.boot
        spring-boot-starter-parent
        3.1.0
       
   
   
        <java.version>17</java.version>
        <solace-spring-cloud.version>3.0.0</solace-spring-cloud.version>
        <spring-cloud.version>2022.0.2</spring-cloud.version>
   
   
       
           
                org.springframework.cloud
                spring-cloud-dependencies
                ${spring-cloud.version}
                pom
                import
           
           
                com.solace.spring.cloud
                solace-spring-cloud-bom
                ${solace-spring-cloud.version}
                pom
                import
           
       
   
   
       
            org.springframework.boot
            spring-boot-starter-web
           
               
                    org.springframework.boot
                    spring-boot-starter-logging
               
           
       
       
            org.springframework.cloud
            spring-cloud-stream
       
       
            com.solace.spring.cloud
            spring-cloud-starter-stream-solace
       
   

cationWrapper.lambda$andThen$0(SimpleFunctionRegistry.java:619) ~[spring-cloud-function-context-4.0.2.jar:4.0.2]

Hi @GreenRover ,
I wasn’t able to reproduce your issue. It seems to be working for me.
I uploaded a sample project here for you: GitHub - Mrc0113/CloudStreamV3RestController . Can you see if it works for you? Seems like there is something weird going on.
Sample request from browser: http://localhost:8094/temperature/publish/dynamic_topic/orlando/99
Received the output in try-me:

Note I’m using Java: openjdk version “17.0.4” 2022-07-19
Hope that helps!

Hi Marc, thank you very much. Your sample leads me on the correct way.
To reproduce you need to add to your application.yaml
spring:
cloud:
function:
configuration:
streamBridge:
output-header-mapping-expression:
solace_timeToLive: 23000L
solace_senderId: @project.artifactId@${HOSTNAME}
The configuration for “streamBridge” was in spring 2.7 necessary to add custom header configuration based to outbound header.
But with spring 3. I can not get this feature working at all.
I tried:
spring:
cloud:
function:
configuration:
emitTemperatureSensorDynamic:
output-header-mapping-expression:
solace_timeToLive: 23000L
solace_senderId: @project.artifactId@
${HOSTNAME}
Than my application stops crashing but i am unable to put those additional outbound header to the message. Because “emitTemperatureSensorDynamic” is not in function registry.


But “streamBridge” is still in function registry.
Do you remember the original issue for this feature. I want to link it when creating a bug report for oleg.

@GreenRover , I’m glad that helped! I believe this is the issue that kicked off the header mapping expression creation: Map incoming header to more refined customer header · Issue #676 · spring-cloud/spring-cloud-function · GitHub

@marc.dipasquale I created a bug report: "output-header-mapping-expression" is not working for streamBridge · Issue #1044 · spring-cloud/spring-cloud-function · GitHub
May be you want to join the discussions