Skip to content

ProtobufJsonPayloadConverter does not work correctly with shaded artifact #2792

@rocketraman

Description

@rocketraman

Expected Behavior

The ProtobufJsonPayloadConverter does not work correctly when using the shaded Temporal artifact, which is sometimes necessary to avoid gRPC version conflicts.

The problem is:

if (!(value instanceof MessageOrBuilder)) {
return Optional.empty();
}

Here, MessageOrBuilder is rewritten in the byte-code to be io.temporal.shaded.com.google.protobuf.MessageOrBuilder, and so passing in a non-shaded value (as certainly client code will be using) fails, and the converter fails to convert the value.

The converter, whether it is shaded or not, should correctly recognize protobuf values coming from client code.

Actual Behavior

Protobuf values coming from client code are ignored, and serialization fails.

Steps to Reproduce the Problem

Using the shaded temporal artifact, run this code:

import com.google.protobuf.StringValue;
import io.temporal.common.converter.ProtobufJsonPayloadConverter;

class Test {
    public static void main(String[] args) {
        var converter = new ProtobufJsonPayloadConverter();
        var msg = StringValue.of("hello");
        var payloadOpt = converter.toData(msg);
        System.out.println(payloadOpt.isPresent());
    }
}

We can see that the payload is not present.

Specifications

  • Version: 1.32.1
  • Platform: N/A

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