Skip to content

ClassCastException in CloudEventMessageUtils.determinePrefixToUse #1331

@rd-max-hartmann

Description

@rd-max-hartmann

Version: spring cloud function 5.0.1

when message header specversion is byte[] instead of string then a ClassCastException is thrown:
java.lang.ClassCastException: class [B cannot be cast to class java.lang.String ([B and java.lang.String are in module java.base of loader 'bootstrap')
at org.springframework.cloud.function.cloudevent.CloudEventMessageUtils.determinePrefixToUse(CloudEventMessageUtils.java:382)
at org.springframework.cloud.function.cloudevent.CloudEventMessageUtils.determinePrefixToUse(CloudEventMessageUtils.java:362)
at org.springframework.cloud.function.cloudevent.CloudEventMessageUtils.getType(CloudEventMessageUtils.java:197)

I guess the cause is this line:
if (StringUtils.hasText(prefix) && (strict || StringUtils.hasText((String) messageHeaders.get(prefix + _SPECVERSION)))) {
return prefix;
}

the byte[] case is not handled here.

thx Max

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions